问题
Hi I'm using parsleyjs for my form validation.
http://parsleyjs.org/documentation.html
I want a custom validator so that an input value can not equal what I specify...
An example using jQuery validation can be seen here... How to add a Not Equal To rule in jQuery.validation
I'm thinking something like..
$( '#form' ).parsley( {
validators: {
notEqual: function ( val, ??? ) {
return val != ??? ;
}
}
, messages: {
notEqual: "Please enter a valid value"
}
} );
Thanks
回答1:
This worked for me. You also have to set data-notEqual="#element"
.
validators: {
notEqual: function ( val, elem ) {
return val !== $( elem ).val();
}
},
messages: {
notEqual: "This value should not be the same."
},
Hope this is what you are looking for!
来源:https://stackoverflow.com/questions/19361050/parsley-js-custom-validator-not-equal-to