Avatar of movieprodw

asked on 

javascript check input pattern and add class if correct pattern


I would like to use javascript/jquery to see if the input of a text field fits the serial number pattern, if so I want it to add the class 'snmatch' if not I want it to have the css class 'nosnmatch'

	.nosnmatch { border: solid 1px blue; }
	.snmatch { border: solid 1px green;	}
<form method="post" id="sncheck">
	<input type="text" class="nosnmatch" name="snumber" placeholder="Please enter your serial number PPR0000000" />

Open in new window


Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon