Avatar of movieprodw
movieprodw

asked on 

javascript check input pattern and add class if correct pattern

Hello,

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'

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

Open in new window

CSSJavaScript

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon