How To Validate Text Field not accept 0 as First digit and Whole digit using Javascript -
how validate text field not accept 0 first digit , whole digit using javascript. example, should not accept
0,00,000,01,02,001 , on
it accept
10,100,10000 , on
any appreciated
get first character of entered string/value, , check 0, on event want check, modify accordingly.
<input id="myid" value="0123" /> $('#myid').blur(function(e){ var first_char = $("#myid").val().substring(0, 1); if (first_char == 0){ return false; } });
hope helps
$( document ).ready(function() { $('#myid').blur(function(e){ var first_char = $("#myid").val().substring(0, 1); if (first_char == 0){ alert('first character 0'); }else{ alert('first character not 0'); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input id="myid" value="0123" />
Comments
Post a Comment