Isaac
asked on
Regular Expression validate SSN
How come the following does not work? What am I doing wrong?
https://jsfiddle.net/isogunro/b3qdvufy/1/
<input type="text" id="ssn" placeholder="xxx-xx-xxxx">
<button id="ssValidate" onclick="valSSN()">
Validate
</button>
function valSSN(){
var ssn = document.getElementById("ssn").value;
var regExpression = /^[/d{3}]-[/d{2}]-[/d{4}]/;
if(regExpression.test(ssn)){
alert("valid");
}else{
alert("invalid");
}
}
https://jsfiddle.net/isogunro/b3qdvufy/1/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.