Consulting,  sites,  WordPress

Leveraging jQuery for Input Validation

jQuery is the most popular JavaScript library in use at this point, finding its way into something around 20% of the largest websites in the world. One of the main reasons for this is that much of jQuery is meant to allow for working between JavaScript and Ajax. As such it often ends up getting used for graphical interfacing. One interesting use for graphics is to only allow someone to actually enter specific characters into fields. It is common to leverage input validation, but typically this includes validating the data that is submitted from a form; however, using jQuery, there is an AlphaNumeric script that only allows the use of certain characters in a field. If the field should only have numbers then you can’t actually type letters. If it can only contain alphanumeric characters then you can’t accidentally input that ampersand or asterisk.

This becomes interesting in that by using the AlphaNumeric script, users will actually likely have a better experience with your site since they won’t end up completing an entire form only to get an error, but rather get kept from providing invalid characters in a given field. AlphaNumeric is also clean and well written; love this script!