Lines 314-328
$(document).ready(function(){
Link Here
|
314 |
$.validator.addMethod( |
314 |
$.validator.addMethod( |
315 |
"phone", |
315 |
"phone", |
316 |
function(value, element, phone) { |
316 |
function(value, element, phone) { |
317 |
var e164 = "^\\+?[1-9]\\d{1,14}$"; |
317 |
let e164_re = /^(\+[1-9]\d{0,2})?\d{1,12}$/; |
318 |
var re = new RegExp(e164); |
|
|
319 |
|
320 |
let has_plus = value.charAt(0) === '+'; |
318 |
let has_plus = value.charAt(0) === '+'; |
321 |
value = value.replace(/\D/g,''); |
319 |
value = value.replace(/\D/g,''); |
322 |
if ( has_plus ) value = '+' + value; |
320 |
if ( has_plus ) value = '+' + value; |
323 |
element.value = value; |
321 |
element.value = value; |
324 |
|
322 |
|
325 |
return this.optional(element) || re.test(value); |
323 |
return this.optional(element) || e164_re.test(value); |
326 |
}, |
324 |
}, |
327 |
jQuery.validator.messages.phone); |
325 |
jQuery.validator.messages.phone); |
328 |
|
326 |
|
329 |
- |
|
|