I have a regular expression pattern, which validates for a three digit number
/^\\d{3}$/.test(\"123\") // true /^\\d{3}$/.test(\"123.\") // false <
/^\\d{3}$/.test(\"123\") // true /^\\d{3}$/.test(\"123.\") // false
You would be better off by using a library like maskedinput.js. You can then setup your text input like follows:
jQuery(function($){ $("#your_input").mask("999"); });
UPDATE
you can use a validator for forms and preset specific types of fields to validate