I have a very big form with a lot of inputs inside. Some of those inputs are mandatory and I need to check them with jQuery 1.3.2. I am using NOT a submit button but a <input type ="button"> -- I need to use that because I have to fire an ajax call when the button is clicked.
So what the code should do is:
Check if the mandatory fields are properly entered.
If the mandatory fields are NOT properly entered an image should be shown.
If the mandatory fields are correct then the ajax call can run.
As you may see some fields are repeated, so the code should be able to work also on ANY repeated/duplicate input (same Name and ID)
<form action ="">
<!-- First Author -->
Author Name: <input type="text" id="AuthorName" name="authorNAMEinput">
<img src="error.png" style="display:none">
Author DOB: <input type="text" id="AuthorDOB" name="authorDOBinput">
Author Company: <input type="text" id="AuthorCompany" name="authorCompanyinput">
<img src="error.png" style="display:none">
<!-- Second Author -->
Author Name: <input type="text" id="AuthorName" name="authorNAMEinput">
<img src="error.png" style="display:none">
Author DOB: <input type="text" id="AuthorDOB" name="authorDOBinput">
Author Company: <input type="text" id="AuthorCompany" name="authorCompanyinput">
<img src="error.png" style="display:none">
<!-- Third Author -->
Author Name: <input type="text" id="AuthorName" name="authorNAMEinput">
<img src="error.png" style="display:none">
Author DOB: <input type="text" id="AuthorDOB" name="authorDOBinput">
Author Company: <input type="text" id="AuthorCompany" name="authorCompanyinput">
<img src="error.png" style="display:none">
<input type ="button" id="authorbutton" name="authorbuttoninput">
</form>
Now lets say that the mandatory fields are AuthorName and AuthorCompany.
I know how to proceed with the jQuery $.get and with the button onclick function, but I do not know how to BEFORE validate those mandatory fields and fire the $.get function onclick ONLY if the fields are properly entered. And I do not know how to make <img src="error.png" style="display:none"> visible if the entered fields are not valide (make it visible for each NON-validate field).
idis invalid mark-up, as anidmust be unique within the document, a duplicatenameis valid, as far as I know, but unless it's in the formname[]the last value submitted with that name will over-write any earlier values.name="authors[]"which submitsauthorsas an array, accessible to, for example, php (on the subsequent page/script) as$_POST['authors']