I use jasny bootstrap with inputmask to validate input.
http://jasny.github.io/bootstrap/
Having the following code.
<input id="foo" type="text" class="form-control" data-mask="999-99-999-9999-9" placeholder="ISBN">
How can I clear the value of the input field? I have tried the following:
$("#foo").val('');
It doesn't clear the value. The previously entered value is still there. It feels like the jasny inputmask object has some state, which I'm unsure how to reset.
All u need to do is use html code
<input id="foo" type="text" class="form-control" data-mask="999-99-999-9999-9" placeholder="ISBN">
<input type="button" id="clear" value="clear">
and the script
<script type="text/javascript">
$(document).ready(function() {
$("#clear").click(function(){
$("#foo").val("");
});
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.