Infotekka Banner Logo
 
Tk Validation
Monday, 25 October 2010 1430 MDT

For any developer one of the most tedious things while developing sites is form validation, and beyond the tedium is a way to make it look good and interact well with the end user. We built the Tk Validation library to make some of this validation easier, specifically for the client side. Naturally, a JavaScript solution is not by any means a replacement for server side validation but often times we want the end user to complete more fields than what is truly necessary to ensure the integrity of the post receiver process.

Enter the Tk Validation library. To use it all you need to do is add it (of course) to your page, and then append the appropriate class name to each input field that you want to validate. The idea is to minimize the amount of JS that actually needs to be inserted into the page, so by using the class names for each input (which will legally accept multiple values) it simplifies the process for the developer. In fact, you do not need to know anything about JavaScript to use this!

The various classes that we can add are:

Class Name Validation Function
tk_text Simply require some kind of string value in the input
tk_posint Require a positive integer value
tk_anynum Any numeric value
tk_currency Require a currency value, and will convert any numeric value to currency or a non numeric value to 0
tk_email Email address
tk_match([id of object to match]) Match another input (good for email confirmation or password confirmation); enter the ID of the other input in parentheses to check against. This works best if you set the other input to require a value.
tk_dropdown([value that is not valid])etc) Force a selection from a dropdown
tk_chars([integer number of minimum characters]) Require a certain number of characters (set the number with an integer in parentheses
tk_phone([delimeter to be inserted after validation]) Require a phone number, this will format using the delimiter that you enter inside the parentheses
tk_submit This is the submit button on the form, setting this will force a check of all fields before the form is submitted. Additionally this inpu will be enabled on page load, so you should set it to be disabled by default. This way, if someone has JavaScript disabled they will not be abe to submit the form.


You can see an example of the JS validation in action here, you can also download or link directly to the library from the links on that page.

Please sign in to leave a comment

Eventually - Tuesday, 9 November 2010 1312 MST
I swear I will eventually release a version 2 of this library; I have a number of ideas on how to make it better but no time to do it.
 
Search Infotekka
 
 
User Login


 
Create an account
 
 
Infotekka SharePoint

Looking for our SharePoint development site? Look no further.

Not looking for it? Maybe you should be. Infotekka specializes in Microsoft SharePoint 2010 architecture, installation, configuration, and most importantly customization. If you'd like to know more please send us a note from the contact page.

 
 
Changes Ahead

The time has come to retire this website and implement a new one. We're likely going to stick with the same look and feel but it's moving off of it's current LAMP environment and going into .NET, where we can take advantage of all the fun integration stuff we're always crowing to our clients about.

Stay tuned for updates!

 
 
 
©2010 infotekka.com