regex - javascript regular expression replace in input form validation -


when inputting string format:

the beginning r or r, non-digit letters, want replace string r.

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

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -