I have a form in which you have to input your phone number and other fields.
I'm validating the form with jQuery Validate.
To validate the phone number field I do:
rules: {
phone: {
required: true,
minlength: 9,
number:true
},..
But I need to check also that phone starts with 6.
How can I do that?
You can also try simple Javascript function
Note: This comment/code is for those who are not using jquery validate.
I think you will need to add a custom validator.
You can add a custom validator
and use it like this:
You need to edit the regex inside
phone_number.match
to suit your requirements.