I was wondering if anyone could offer some suggestions on how to validate a social security number & their employee # that a user would input separately through prompts?
The SS# would be in the form of xxx-xx-xxxx where the x's are 0-9. I tried using this function that I wrote
bool isInt(string mystring)
{
int i;
for (i=0;i<mystring.length();i++)
{
if (!isdigit(mystring[i]))
return false;
else
return true;
and this code in my main to do it
cout<<"Please enter your social security number: ";
getline(cin, socialSecurity);
cout<<endl;
//input validation
result = isInt(socialSecurity);
if (!result)
{cout<<"Your social security number isn't valid."<<endl;
cout<<"Please enter a valid number."<<endl;
cout<<endl;
}
while (!result);
but it still just lets me type in whatever into socialSecurity, including letters.
The employee number is xxx-L, where x is 0-9 and L can be any letter from A-M.
Thanks!