Aleks
asked on
regexp for SSN validation
I have the code below to validate an expression, in this case a name. I need to change the regexp: regexp: /^[a-z\s]+$/i,
to something that will validate a SSN. I am not familiar with this and I am in sort of a rush to finish this today, help is appreciated.
My current code is below. All I need changed is the regexp.
Thank you in advance.
to something that will validate a SSN. I am not familiar with this and I am in sort of a rush to finish this today, help is appreciated.
My current code is below. All I need changed is the regexp.
$(document).ready(function() {
$('#regexpForm').formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
fullName: {
validators: {
regexp: {
regexp: /^[a-z\s]+$/i,
message: 'The full name can consist of alphabetical characters and spaces only'
}
}
}
}
});
});
</script>
Thank you in advance.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried the code below but I can still enter letters no problem.
Same for: ^\d{3}-\d{2}-\d{4}$
IS there a syntax or other problem in the code ?
SSN: {
validators: {
regexp: {
regexp: /^(?!000)(?!666)[0-8][0-9]{2}[- ](?!00)[0-9]{2}[- ](?!0000)[0-9]{4}$/,
message: 'Please enter the SSN in the correct format (XXX-XX-XXXX)'
}
}
}
},
Same for: ^\d{3}-\d{2}-\d{4}$
IS there a syntax or other problem in the code ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Unfortunately no, it is an intranet.
I have other validations inside the same script which work fine :$
I have other validations inside the same script which work fine :$
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window