Phone Number Validate JQuery

This script will check following thing in Phone
  1. Phone is not String
  2. Phone number must not starting with 0 or 1
jQuery('#phone').keyup(function (e)
{
var phonevalidate = jQuery('#phone').val();
    var checkfirstval = phonevalidate.charAt(0);
if(checkfirstval==0 || checkfirstval==1){
jQuery('#phone').val('');
}
var regEx=/[^0-9]/;
var checkstring = regEx.test(phonevalidate);
if(checkstring){
jQuery('#phone').val('');
}
});

Note: Here input id is phone.

Popular posts from this blog

Cant use dump() function in twig files or how to enable debug in opencart twig or print_r alternate use dump() in opencart 3.0

maximum execution time error when importing sql data file since php.ini has been already set max execution time 3000

SEO Custom URL in Opencart