remove leading zeros in javascript
Mobile No(beginning With Zero ) :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function removeZero(s) {
while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,500); }
return s;
}
function removeFirstZero(){
alert("orisinal value : "+$('#txtmobile').val());
var mob=removeZero($('#txtmobile').val());
alert("After remove Zero : "+mob);
$('#txtmobile').focus();
return false ;
}
</script>
Mobile No(beginning With Zero ) :
<input type="text" name="txtmobile" id="txtmobile" style="width:300px" class="required"/>
<input type="submit" name="btnsubmite" class="myButton" onclick="return removeFirstZero();" id="btnsubmite" value=" Get Value "/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function removeZero(s) {
while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,500); }
return s;
}
function removeFirstZero(){
alert("orisinal value : "+$('#txtmobile').val());
var mob=removeZero($('#txtmobile').val());
alert("After remove Zero : "+mob);
$('#txtmobile').focus();
return false ;
}
</script>
Mobile No(beginning With Zero ) :
<input type="text" name="txtmobile" id="txtmobile" style="width:300px" class="required"/>
<input type="submit" name="btnsubmite" class="myButton" onclick="return removeFirstZero();" id="btnsubmite" value=" Get Value "/>
Comments
Post a Comment
If you Satisfied , Please Leave a comment