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

mysql - How to unscape text from database in android studio -

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

Making CSS Drop Down Menu 2 Columns -