ndwest12
09-06-2011, 03:06 PM
This is what I have so far, it is a template I copied from my working E-mail validation. I'm assuming I have to make it so it's just an array of numbers but I really don't know Java too well.
Essentially I just want numbers only to be accepted into the phone field.
else if(fieldType == 'phone')
{
if((required == 1 && fieldObj.value=='') || (fieldObj.value!='' && !validate_phone(fieldObj.value)))
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
function validate_phone(phoneStr)
{
apos=phoneStr.indexOf("@");
if (apos<1||dotpos-apos<2)
{
return false;
}
else
{
return true;
}
}
Essentially I just want numbers only to be accepted into the phone field.
else if(fieldType == 'phone')
{
if((required == 1 && fieldObj.value=='') || (fieldObj.value!='' && !validate_phone(fieldObj.value)))
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
function validate_phone(phoneStr)
{
apos=phoneStr.indexOf("@");
if (apos<1||dotpos-apos<2)
{
return false;
}
else
{
return true;
}
}