I am using jquery validation plugin
I added a custom method using addmethod , which in turn calls another UK telephone number validation method
here is my code (simplified):
HTML
<form id="myform"> <label for="field">Required, telephone: </label> <input class="required" id="field" name="field" /> <br/> <input type="submit" value="Submit" /> </form>
JQuery
$(document).ready(function(){ $("#myform").validate({ rules:{ field:{ required:true; UKTelNumber:true } } }); }); jQuery.validator.addMethod("UKTelNumber", function(value,element) { if (!checkUKTelephone (value)) { alert (telNumberErrors[telNumberErrorNo]); return false; } else { return true } },jQuery.validator.format(telNumberErrors[telNumberErrorNo]));
The checkUKTelephone function sets the var telNumberErrorNo value according to the type of error. All error messages are present in the telNumberErrors array.
My requirement now is how to display the error messages that are now being warned.
passing jQuery.validator.format(telNumberErrors[telNumberErrorNo]) as a message (third option) addmethod does not help.
I also tried passing only this telNumberErrors[telNumberErrorNo] , but it only showed one message every time the message contained in telNumberErrors[0]
plz help me
Thank you in advance
source share