regex - javascript regular expression replace in input form validation -
when inputting string format:
the beginning
r
orr
, non-digit letters, want replace stringr
.
it's in situation:
onkeyup="this.value=this.value.replace(/^[rr]\d/g,'r')"
but not work.
somebody can me out? thanks.
use following regex:
onkeyup="this.value=this.value.replace(/^[rr]\d+/, 'r')";
see demo:
<input onkeyup="this.value=this.value.replace(/^[rr]\d+/,'r')" />
Comments
Post a Comment