How can I resolve spaces within the verification of numbers only, with a minimum of 8 digits? Phone numbers are much easier to enter when spaces are allowed. e.g. 0400 123 456, 9699 1234.
Here is my code so far, I only have validation of at least 8 digits:
jQuery.validator.addMethod(
"phone",
function(phone_number, element) {
return this.optional(element) || /^\d{8}$/.test(phone_number);
},
"Please enter numbers only"
);
source
share