1

By form submit using "jQuery validator" for input field validation. I want to validator phone number its working fine but that problem is phone number must start with '+'.

So I am using RegEx

/\+[91][0-9]{10}/

my jQuery rules is

$("#commentForm").validate({
    rules: {
        phoneNumber: {
            matches: "/\+[91][0-9]{10}/",
            required: true,
            minlength: 10,
            maxlength: 10,
            number: true
        }
    }
});

That above code is not working, is its correct for add matches field RegEx to jQuery validator

Tushar
  • 85,780
  • 21
  • 159
  • 179
Balaguru Murugan
  • 463
  • 2
  • 7
  • 21

1 Answers1

0

is the area code always 91? in your test will only match area codes 9 or 1 followed by 10 numbers, if it is always 91 you can try /\+91[0-9]{10}/

if you want to match this +(91)(9876546719) and +919876546719 you can use

/\+\(?91\)?\(?[0-9]{10}\)?/
Conrado Costa
  • 434
  • 2
  • 12