I am trying to validate user-entered values ββin an input text box. When they enter a value and click Submit, if the value entered matches the value in the array, I am trying to create one result, if not in the array, another result.
Basically, there is a simple form:
<form id="checkinput" action="#"> <input type="text" value="" id="couponcode" name="coupon code name"/> <input type="button" id="submit" value="Submit"/> </form>
When you press "#submit", if the value in the input field "#couponcode" is equal to the value in the array, add the class "success" in the div with the identifier "success_show", otherwise a simple warning, for example, your coupon code is incorrect, will be displayed.
I will have a hidden div and after success add the class "success" to the div.
The array will periodically change and will have different values ββat different times. Something simple:
var arr = [ "CA238", "Pete", 8, "John" ];
source share