I want validation on text box for phone number which allowed
Allowed chars:
space + ( ) - 0-9
(or + can be first char after trim, like (+61) 312 405 786 or +61 312 405 786)
Length: min 8, max 16.
Please help.
I have tried but I am not able to get correct Regex.
function phNum(val) {
var subjectString = val;
var regexObj = /^\(?([0-9][- ]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{3})$/;
if (regexObj.test(subjectString)) {
var formattedPhoneNumber = subjectString.replace(regexObj, “+61$1$2$3”);
document.getElementById(‘a’).value = formattedPhoneNumber;
}
}
nmn
But its not works for me…………
get a regex for your needs
http://regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7&AspxAutoDetectCookieSupport=1