forum

Home / DeveloperSection / Forums / How to Prevent zero as first digit in an numeric only textfield in jquery?

How to Prevent zero as first digit in an numeric only textfield in jquery?

Anonymous User229031-Oct-2014
How do I restrict if the first digit is zero (0)

$('.btn').keypress(function(e) {
      var code = e.which;
      if(($(this).val().indexOf(".") == -1 && code == 46) || (code >= 48 && code <= 57) || (code == 8) || (code >= 48 && code <= 57)){
          returntrue;
        }              returnfalse;
    })
    .bind('paste',function(e) {
    e.preventDefault();
});   


Updated on 31-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By