Ty44ler Posted November 19, 2009 Share Posted November 19, 2009 I'm trying to not allow my users to enter in n/a in my form ex... "N/A" "n/A" "na" My code trips the alert every time no matter what is entered in the cell... Why is it doing that? function appliance() { if (document.ComplianceForm.Appliance.value=="n/a" || "N/A" || "n/A" || "N/a") { alert("You cannot enter any variation of n/a in this cell.") } else { return false; }; } Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2009 Share Posted November 19, 2009 you have to compare the field with each value like the following the reason its not working because a string returns true if ("N/A") will return true function appliance() { var appliance_value = document.ComplianceForm.Appliance.value; if (appliance_value=="n/a" || appliance_value == "N/A" || appliance_value == "n/A" || appliance_value == "N/a") { alert("You cannot enter any variation of n/a in this cell.") } else { return false; } } Quote Link to comment Share on other sites More sharing options...
Ty44ler Posted November 19, 2009 Author Share Posted November 19, 2009 ahh thank you so much! I knew it was something simple. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.