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

php - Admin SDK -- get information about the group -

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

Python Error - TypeError: input expected at most 1 arguments, got 3 -