I am trying to replace the leading zero from a input field.
I am trying this but getting no luck
var regex = replace(/^0+/, "");
I am trying to replace the leading zero from a input field.
I am trying this but getting no luck
var regex = replace(/^0+/, "");
You don't have a string in your example. Try something like this:
var foo = '012345';
var bar = foo.replace(/^0+/, '');
Your regex is correct try using like this:
$ele.val(function(i, val) {
return val.replace(/^0+/, "");//sets the value of each element to the original value without 0 padding
});
Something like this:
$("field_id").val($("field_id").val().replace(/^0+/, ""));
or this:
$("field_id").val(function(i, val){ return val.replace(/^0+/, ""); });