-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't validate fields with name like "fieldname[]" #140
Comments
A pull request would be much appreciated in this area :) |
Hi, @rickharrison I would like to work on this issue. Can you please assign me? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have select element like this:
<select name="degree[]">
<option value="">Select</option>
<option value="High School" >High School</option>
<option value="Diploma" >Diploma</option>
<option value="BA" >BA</option>
</select>
new FormValidator('applyform', [{
name: 'degree[]',
display: 'Degree',
rules: 'required'}], function(errors, e){
/* if(errors.length > 0) is always true even if "degree[]" select is selected*/
});
Fix suggestion, inside attributeValue plugin function, before the last "return", I added
if ((attributeName == 'value') && (element.length > 0) && (element[0].type === 'select-one')) {
_v = new Array();
for (i = 0, elementLength = element.length; i < elementLength; i++) {
if(element[i][attributeName] && element[i][attributeName].length > 0){
_v.push(element[i][attributeName]);
}else{
return ''; // stop looping, found empty value!
}
}
return _v; // return array of collected values
}
The text was updated successfully, but these errors were encountered: