Category Archives: Javascript

How to limit input control to accept only numeric or alpha numeric

Often it is a pain in the neck to validate text boxes for invalid characters. In some cases we expect only numbers, in some cases alpha numeric. It is easy to fix this issue with jquery

Add this snippet your js file or page. Make sure you referenced jquery. Now simple use the class “alphanumericOnly” for the text boxes for alpha numeric, and “numericOnly” class for text boxes which expects numeric only.

How to set cookie with javascript

A simple yet useful code. Setting cookie with javascript.

It can be useful we try to store somevalue from the client side itself.

How to track changes in a page using jquery

Let as imagine, we need to show the user a confirmation message when he changed something in a page and tries close the page, how to do it ?. Well, here I am presenting a simple way to do that with jquery.
First step is to add a hidden element in your html code

Assuming that you have added the jquery library already, add the following javascript code in your page

Hurrey, you are done. Now if you changed anything in your page and tries to close your page before it is saved, the page will show a confirmation message. However, if you are saving the data using ajax, do not forget to set the value of “haveChanges” to false after saving. So that was it, cheers and happy coding fellas.

Most simple slideshow using jquery

Here I present before you a simple image slideshow script using jquery. It is faster and compatible with all browsers (Tested in Mozilla 3+, IE7+,Opera,Safari and Chrome).

CSS:

Javascript:

Html:

Credit: http://snook.ca/archives/javascript/simplest-jquery-slideshow

Cheers