I have a form which has got five (5) file input controls along with other controls. This form also has got two (2) submit buttons.
I have used JQuery Validation plugin to validate form inputs.
Name of one submit button is "Upload_Images" and name of another is "Upload_Project".
What I want to do is that if user clicks on "Upload_Images" button all files controls should be validated and files uploaded to server but not rest of the data.
If use clicks on "Upload_Project" button then the whole form should be validated and the files are not already uploaded they should be first uploaded and then the project should be saved to DB.
Now if I click on any of the two submit buttons the form Validation kicks in and if there is invalid data it stops form submit process.
How can I achieve this?
Use javascript to change your form 'Action' property to redirect to wherever other page you need to go, then submit.
Related
I'm working on editing an existing PHP form that seems to use Bootstrap to do the field validation (telling me if a required field is missing).
Currently, when you fill out the form and click Submit, a modal pop-up comes up that basically just prints your form data so you can review it before submitting. Then, within that modal is another Submit button that actually submits the form.
However, the validation of determining whether all the required fields are filled out only happens on the 2nd Submit button, not the first.
Is there a way I can tell my 1st Submit button to do the validation, and only open the modal pop-up if the validation passes?
Hello you can use Jquery. You can check with jquery first form values. If you need check with php you can use Ajax.
I have a form that contains both data inputs and file inputs. Now i want to upload files selected right after selection without submitting the form, because form submit will send other data. The reason that i want upload files before submitting form is saving the time, so when the user is filling the form, files will be uploaded.
As i understood i need to use iframes, because ajax can not simply send files, and formData is not supported in IE. But i couldn't find a clear example of it.
Any idea how to do it?
I have a form our guests use to submit a post to a very simple 'message board'.
Now we want to allow the users to upload 1-10 files, but the concern or requirement is to do this outside of the MAIN form submit.
MAIN FORM consists of:
input field 1
input field 2
text area 1
Submit button
I currently have it so there is an initial browse button.. ( below the text are and to the left of the main submit button) and once a file is picked.. and display a link for the user to add another 'browse' field..
What I would like to do is have an UPLOAD button below all these dynamically created browse/file upload fields... that will send all the file data to an external .php script to upload the files in question, and then just return the file path/name back to the main form (maybe in hidden fields? I dont care).. so that these file path/name string values are submitted when the MAIN FORM is submitted..
hope that make sense.
Is this possible? And if so how do I go about this? The concern is to handle the asset uploading/file handling outside of the main form submission so the users details are not lost if something goes wrong with the file upload portion of things.
You can do this with JQuery and Ajax. There are various plugins are available for this. You can try this - http://plugins.jquery.com/uploadfile/
I'm just trying to understand the submit button within php.
I know that it performs that action stated within the form tag. So basically what I have is an form tag that only defines it's ID, i.e. no method attribute nor action. And within this form is a submit button. This input element only defines the type as submit, i.e. no name attribute nor id nor value.
Quickly describing the file: It has two input text elements which are required and a submit button. When i view this file in chrome, and i've clicked the submit button, a pop up shows below the required fields which i have not entered text in stating "required field".
I love this function however, it doesn't check for spaces, i.e. " ".
So back to my question, could someone possibly tell me what the submit button actually does or possibly what methods does it call when i click on it even though the form it is in has no action defined.
When the button is clicked, the browser detects this and submits the form back to the server. This has nothing to do with PHP, it's simply the browser implementing what the HTML specification stipulates.
Since your form does not have an action attribute, what happens is that the browser gathers the values of all eligible input controls in the form, turns that into a query string and makes an HTTP GET request to the current URL using that query string. The HTML5 spec covers this in detail.
The submit button offers one possible interface for the submission of the form. It's like the send button for a text message. While there are alternatives to submit the form, the submit button is the HTML option.
When a form's action is empty, the form submits the GET data to the page that form is on. (Basically, it reloads itself, with the new form data attached.) So you could write your PHP code at the top of the same page to manipulate the data.
In your PHP code at the top of the page, you can test whether or not your form sent data in those two required fields. If one or both are empty, you can echo a message to the user telling them the fields are required.
I have a form with a wysiwyg editor and I would like to add a preview button so the user can see how the content would look like in the website.
In order to do this I inserted another submit button wich gets the info from the form and redirects to a preview page.
All ok, but after clicking that button the form content disappears so the user can see a preview but it has no data in the actual form in order to make some changes or to submit the form in order to save the data.
So here's my question: can I have this preview button and also keep the data in the form after clicking the preview button?
What you need is either:
Repopulate the form from the preview function (that means manually fill in the form with the submitted data)
OR
Use Ajax to submit the form to the preview function and keep open the current edition page.
By the way, you can't have two submit for one form.