var str = "3452.345-345";
var format = /^(?=.*\d)[0-9\s\.\-\_\(\)\+]+$/;
if(!format.test(str)){
alert("Invalid input")
} else {
alert("Valid input")
}
Details
(?=.*\d) :- at least one digit should be present
[0-9\s\.\-\_\(\)\+] - given input should be 0 to 9 or symbols like (-_ . space +)
var format = /^(?=.*\d)[0-9\s\.\-\_\(\)\+]+$/;
if(!format.test(str)){
alert("Invalid input")
} else {
alert("Valid input")
}
Details
(?=.*\d) :- at least one digit should be present
[0-9\s\.\-\_\(\)\+] - given input should be 0 to 9 or symbols like (-_ . space +)
No comments:
Post a Comment