Jump to content

Client-side validation using javascript

Recommended Posts

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.

Link to comment
Share on other sites

  • 1 year later...

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;

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...