SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Tuesday, October 4, 2011

Javascript integer alerts

While working on a javascript issue for our project, we notice the strange behavior of integers and strings.We were about to validate  the users Social Security Number and later we noticed if any customer types 001234567, it seems to be changed to a random number 342391.

Hardly its tough for us to save it in database.While debugging via firebug, we noticed during the client side validation , the numbers are changing. Lets try something like alert(000123456) in the javascript console, we will find a random number.

Then we came to conclusion, before passing the numbers for client side validation, we are converting it into string.So that random number won't get generated. So while dealing with the sensitive data like SSN number, please be aware to implement the number as strings instead integers.