html - Masked input field is being cleared if it is not completely entered -
<input id="format_thisformat" name="format_thisformat" type="hidden" value="##-##-##-##" />
so, know go on, basically, issue input field being cleared if complete mask isn't being entered (for example, if "12-44" being input, field clear, if "12-34-56-78" entered, field stay. want ability allow partial inputs. ideas how can edit line accomplish trying achieve? i'm assuming it's issue line, i'm not going post thousands , thousands of lines of code because won't make sense, custom api in visual basic spa.
you can add event listener , check if input valid:
let input = document.getelementbyid('format_thisformat'); input.addeventlistener('blur', (e) => { if(!e.target.value.match(/\d{2}-\d{2}-\d{2}/g)){ e.target.value = ''; } })
<input id="format_thisformat" name="format_thisformat" type="text" />
Comments
Post a Comment