Jump to content
lmooring

Check the Cost is less than Retail

Recommended Posts

Hi Caspio World,

 

I feel like this is an easy one, but I am not able to figure out the java scripting. I have two fields on a submission form; Cost and Retail.

I am looking for a simple data check script to make sure that cost is always less than the retail amount. If Cost is greater, an alert pops up, "cost must be less."

 

Thank you for any assistance.

Share this post


Link to post
Share on other sites
16 hours ago, lmooring said:

Hi Caspio World,

 

I feel like this is an easy one, but I am not able to figure out the java scripting. I have two fields on a submission form; Cost and Retail.

I am looking for a simple data check script to make sure that cost is always less than the retail amount. If Cost is greater, an alert pops up, "cost must be less."

 

Thank you for any assistance.

Hi,

try using my code in the footer of the datapage:

<SCRIPT LANGUAGE="JavaScript">

 function check()
 {
   var v_cost = parseFloat(document.getElementById("InsertRecordFirst_field").value);
 var v_retail = parseFloat(document.getElementById("InsertRecordSecond_field").value);
   
if(v_cost>v_retail) {
     window.alert("Cost must be less");
 return false;
}

}

 document.getElementById("caspioform").onsubmit=check;

</SCRIPT>

Replace First_field with field name where you store cost, and Second_field with field name where you store retail amount.

Hope it helps! :)

Share this post


Link to post
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.

Guest
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.

Loading...

×
×
  • Create New...