Validate Textbox

I have a form where user is entering details. To validate the data for FirstName textbox i use the below code.

if (!$w(‘#firstName’).valid)
validationMessage += ‘Please enter your first name\n’;

However, the textbox takes in any number value and doesnt throw any error. The reason could be the .valid only checks for empty string and not string vs numbers. If I need to add another validation to omit numbers, what would be the code?

Hello sangack.
What you need is a regular expression validation.You can add it in element settings.

Does it only validate or can you also auto format the number?