Home > Enterprise >  Jquery phone number validation start from 30
Jquery phone number validation start from 30

Time:02-11

** Jquery phone number validation ** Jquery phone number validation using regular expression.

valid phone number:- 30344343434, ragex not working and error show:- Uncaught SyntaxError: Invalid regular expression: /^( 30)[0-9]{9}$/: Nothing to repeat

$.validator.addMethod("PhoneValidation", (function(e) {
        let regex =  /^( 30)[0-9]{9}$/.test(e);
        return(regex);
    }), PHONE_VALIDATE);

suggest valid regex.

CodePudding user response:

You can try this

$.validator.addMethod("PhoneValidation", function (value) {
       return /^(\ 30)(30|31|32|33|34|35|36|37|38|39)[0-9]{7}$/.test(value);
}, "Please enter valid number.");

put \ before starting 30 in the first bracket And in the second bracket, put pair with 3 which you want to validate

  • Related