Hi, I am trying to use this approach but it isn't working. I'm hoping you can spot what is wrong with my code.
First, in an html block, I have a show/hide fieldset that is triggered by a checkbox (i.e. check the box if you have a promo code and when the box is checked an input field appears to enter the code). This part works fine:
----------------------
I have a Promo code.
Promo code
----------------------
But I need to validate that only acceptable promo codes are entered into the input field. Since we typically only have one or two codes out there, I thought a simple if, else if, else statement would work. As advised in the previous thread, I have placed the javascript in the footer. Here is my validation function:
function validator(){
var promoValue = document.getElementById("InsertRecordPromo").value;
var capValue = promoValue.toUpperCase();
if (capValue == "ABC"){
return true;
} else if (capValue == "DEF"){
return true;
} else {
alert("Invalid Promo code!");
}
}
document.getElementById(\"caspioform\").onsubmit= validator;