I have a column that holds US phone numbers that we want to have the format 999-999-9999.
The column has validations, one of which is to check for hyphens. I'd like to "help" the user by allowing numbers to be entered without hyphens, and then to validate. How do i call a function to apply formatting before validation occurs?
The jQuery to add the hyphens to a number string would be something like: $(this).val($(this).val().replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'$1-$2-$3'))
My column definition:
{ title: "Phone", width: '15%', dataType: "string", dataIndx : "phone" ,
validations: [
{ type: 'nonEmpty', msg: "Required"},
{ type: 'regexp', value: "^[0-9]{3}-[0-9]{3}-[0-9]{4}$", msg: "That does not appear to be a valid US phone number in the format 999-333-2222 (add the hyphens please!)" },
]
},