I know this question is a lot easier than it seems, but I can't seem to get around it.
This is my current code and I cannot get it to properly check if the SSN number is in a proper format or not. It just says all is false. This is my current code:
<script type="text/javascript">
function checkDgt(){
var validSSN=/\d{3}-\d{2}-\d{4}/;
if(validSSN.test(document.getElementById("social").value))
alert("Social is invalid.");
else
alert("Invalid.");
}
</script>
<form>
<input type= "text" name="social" id="social">
<input type= "button" value="Validate" onclick="checkDgt();">
</form>
What exactly am I doing wrong?