tags:

views:

31

answers:

1

I'm looking for a library that will do some pre-validation functions on my input fields.

For example, when you logging into hotmail, the user's email address is automatically lowercased before the form is submitted.

I want to be able to strip out all none-alphanumeric characters from certain fields, upper/lowercase some input, strip out spaces etc.

Does anyone know of such a library before I go ahead and write all this stuff manually?

+1  A: 

I think the terminology you're looking for is input mask. Wikipedia describes them like so:

an input mask refers to a string expression, defined by a developer, that governs what a user is allowed to enter in as input in a text box. It can be said to be a template, or set format that entered data must conform to

You should check out the jQuery Masked Input plugin.

http://digitalbush.com/projects/masked-input-plugin/

It has several predefined options, but allows you to create custom "input masks" that will meet your needs. You may need to write some custom jQuery code using the .change() and/or .blur() events in addition to input masking (depending on the complexity of your needs).

jessegavin