I would like to have a regular expression which clears an HTML field when the input is not correct. I created this one, but instead of clearing the field when it’s incorrect, it clears it only when the input is correct.
onchange="this.value=this.value.replace(/^([01]?[0-9]|2[0-3]):[0-5][0-9]/,'')"
I’ve tried to ‘reverse’ the code, but it didn’t succeed so far.
1 Answer