It almost seems like these need to be new field types or if not controlled at input, at least forced prior to submission with validation rules.
Can we copy the email validation rule and make the format what we want. For example, I've got issues with both dates and phone numbers in a form I've developed.
While these don't mask the input, it you put the format in the value field for a phone number as ###-###-#### and include the following validation script (I called it ff_validphone) the user will get an error until they enter the proper format. Note that "#" are not valid values in my validation script, so that won't get entered into the DB, only the correct number string would.
function ff_validphone(element, message)
{
var check =
/^([0-9]{3})+\-([0-9]{3})+\-([0-9]{4})+$/;
if (!check.test(element.value)){
if (message=='') message = element.name+" is not valid phone format, please use ###-###-####.\n";
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_validphone
If you wanted to make your format (###)###-####, you would use a validation that looks like this:
function ff_validphone2(element, message)
{
var check =
/^([(]{1})+([0-9]{3})+([)]{1})+([0-9]{3})+\-([0-9]{4})+$/;
if (!check.test(element.value)){
if (message=='') message = element.name+" is not valid phone format, please use (###)###-####.\n";
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_validphone2