only number key in javascript

function IsNumber(evt,x) { var charCode = (evt.which) ? evt.which : event.keyCode ; //alert(charCode); if(charCode != 46 && charCode != 45){ // . = 46 , – = 45 if ((charCode > 31 && (charCode 57)) ) return false; //alert($(‘#txtts’).val()); var s= $(x).val().split(‘.’) ; if(s[1].length > 1){ return false ;}; return true; }else if(charCode==45){ if($(x).val().length!=0) return false ; } if(charCode==46){ if($(x).val().indexOf(‘.’)!=’-1′){ return false ;}; } var s= $(x).val().split(‘.’) ; if(s[1].length > 1){ return false ;}; return true; }

function IsNumber(evt,x)
 {

         var charCode = (evt.which) ? evt.which : event.keyCode ; //alert(charCode);

if(charCode != 46 && charCode != 45){ // . = 46 , – = 45
         if ((charCode > 31 && (charCode 57)) )
            return false;
//alert($(‘#txtts’).val());
var s= $(x).val().split(‘.’) ; if(s[1].length > 1){ return false ;};
         return true;
}else
if(charCode==45){ if($(x).val().length!=0) return false ; }

 if(charCode==46){
 if($(x).val().indexOf(‘.’)!=’-1′){ return false ;};
 }

var s= $(x).val().split(‘.’) ; if(s[1].length > 1){ return false ;};
return true;
      }

 
 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s