Is there anyway to check if a similar value exist in an input box
EX:
<input name="user1" value="bla1">
<input name="user2" value="bla2">
<input name="user3" value="bla1">
The verification will trigger when the form is submitted, it will alert the user and add a class to both the input with the similar value.
More jQuery'ish
var inputs = $('input');
inputs.filter(function(i,el){
return inputs.not(this).filter(function() {
return this.value === el.value;
}).length !== 0;
}).addClass('red');
FIDDLE
Filters the inputs based on wether or not another input with the same value exists
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With