Thursday, January 05, 2006

Charactor Validatin : Java Script

//
//A funtion for check a charactor input in a web form
//
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if ((charCode < 45 || charCode > 57) && charCode != 8 && charCode != 37 && charCode != 39) {
        alert("This field accepts numbers only")
        return false
    }
    return true
}
//
// you can access it from any contorl as follows
//
onKeyPress = 'javascript:return checkIt(event)'

1 comment:

Indika said...

Ohh man, i think you hve spend too much time infront of PC. Hay common, wake up, Im going to use try catch, so that they will, never going to crash, at lest i have a control over that. :)

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...