I’m currently using the jQuery Validate plugin for my input validation.
It is used within a tableview with records which has editable fields.
When I push submit I want everything to be validated and the errors shown in the general errorContainer.
The problem is that I have multiple rows. So when I edit a row’s emailaddress than it tells me that the e-mailadres field is required. But when I change to emailaddresses I can see the error 2 times.
What I want is the following:
- The emailaddress for user1 is required
- The emailaddress for user2 is required
Instead of:
- The emailaddres is required
- The emailaddres is required
The emailadress is required
User1 and User2 is a non editable field in the row.
Can someone help me out?
<table>
<tr>
<td>user1</td>
<td><input type="text" class="email"></td>
</tr>
<tr>
<td>user1</td>
<td><input type="text" class="email"></td>
</tr>
</table>
The input fields need to be validated when the user enters submit with the following jQuery snippet
$("#selfManagementForm").validate(
{
errorLabelContainer:"#validationErrors",
wrapper:"li"
}).form();
According to the options area of the validate documentation, you can provide a
messagesobject to the validate call. To make this work, you really should havename="user1"andname="user2"in your input elements, so they can be referenced by the messages object: