dantila Posted July 23, 2008 Report Share Posted July 23, 2008 Since there seems to be no way to configure a field value for server-side validation, we need to be able to call a client-side script. Your JavaScript examples are limited to on-load activities like calculations, etc. Here's what we need to do: - prior to posting the form back to dp.asp, call custom code, e.g., So, in sum, add the onsubmit property. Any way to do this within the bounds of the system rather than hacking the DOM when the page is loaded? Thanks in advance for the help. Quote Link to comment Share on other sites More sharing options...
Barbara Posted July 25, 2008 Report Share Posted July 25, 2008 Hi, What you actually need is: function validator(){ //YOUR JS CODE } document.getElementById(\"caspioform\").onsubmit= validator; Put the script in the footer of the Caspio DataPage. Try it out! Barbara Quote Link to comment Share on other sites More sharing options...
pse_cs Posted June 18, 2010 Report Share Posted June 18, 2010 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; 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.
Note: Your post will require moderator approval before it will be visible.