Jump to content
lmooring

If..Then Statement in Submission Form

Recommended Posts

I need to create an alert on a submission form where,

 

If the drop down box PACKTYPE is = "Simple" then if text field SIMPLEUNIT not equal to 1

Else if PACKTYPE is = "Complex" then a second text field COMPLEXUNITS must be =<2 or greater than 1, which ever is easier.

 

I would like to include alert messages if possible. I am not sure how to write this. I am sure it is simple but I am not familiar enough and not in submission forms. I've only seen items for reports.

 

Any help is appreciated!

Edited by lmooring

Share this post


Link to post
Share on other sites
On 6/21/2017 at 8:53 AM, lmooring said:

I need to create an alert on a submission form where,

 

If the drop down box PACKTYPE is = "Simple" then if text field SIMPLEUNIT not equal to 1

Else if PACKTYPE is = "Complex" then a second text field COMPLEXUNITS must be =<2 or greater than 1, which ever is easier.

 

I would like to include alert messages if possible. I am not sure how to write this. I am sure it is simple but I am not familiar enough and not in submission forms. I've only seen items for reports.

 

Any help is appreciated!

Hi,

I'm afraid that the condition is not clear to me.

if  PACKTYPE is = "Simple"  then you need to check that  field SIMPLEUNIT not equal to 1 ? Does it mean that you allow all other values except 1?

 if PACKTYPE is = "Complex" then you need to check that a value in the second text field COMPLEXUNITS is between 1 and 2, correct ?

So, you just need to validate (not assign) values in the SIMPLEUNIT  and COMPLEXUNITS fields. 

Share this post


Link to post
Share on other sites

Hi, Sorry for the confusion. I retyped it several times before posting trying to make it clear.

I've reread the specs and discussed with the business owner. This is how I now understand it and yes, it is validation.

 

IF PACKTYPE = "SIMPLE"

THEN SIMPLEUNIT should be EQUAL to "1"

 

IF PACKTYPE = "COMPLEX"

THEN COMPLEXUNIT should be >= to "2"

Share this post


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

Hi, Sorry for the confusion. I retyped it several times before posting trying to make it clear.

I've reread the specs and discussed with the business owner. This is how I now understand it and yes, it is validation.

 

IF PACKTYPE = "SIMPLE"

THEN SIMPLEUNIT should be EQUAL to "1"

 

IF PACKTYPE = "COMPLEX"

THEN COMPLEXUNIT should be >= to "2"

I also added a condition to check that fields are not blank. You need to use your field names instead of mine.

<SCRIPT LANGUAGE="JavaScript">

 function check()
 {
var COMPLEXUNITS= parseFloat(document.getElementById("InsertRecordCOMPLEXUNITS").value);
var SIMPLEUNIT = parseFloat(document.getElementById("InsertRecordSIMPLEUNIT").value);
var PACKTYPE = document.getElementsByName("InsertRecordPacktype")[0].value;
   
if( PACKTYPE =='Simple' ) {
if (SIMPLEUNIT !=1 || typeof SIMPLEUNIT  == 'undefined' || !SIMPLEUNIT || SIMPLEUNIT.length  === 0 || SIMPLEUNIT  === "" || !/[^\s]/.test(SIMPLEUNIT) || /^\s*$/.test(SIMPLEUNIT) || SIMPLEUNIT.replace(/\s/g,"") === "" )
{
window.alert("Value in the SIMPLEUNIT field should be equal 1");
return false;
}
}
else if (PACKTYPE =='Complex'){

if ( COMPLEXUNITS <2 || typeof COMPLEXUNITS == 'undefined' || !COMPLEXUNITS  || COMPLEXUNITS.length  === 0 || COMPLEXUNITS  === "" || !/[^\s]/.test(COMPLEXUNITS ) || /^\s*$/.test(COMPLEXUNITS ) || COMPLEXUNITS .replace(/\s/g,"") === "")
{
 window.alert("Value in the COMPLEXUNITS field should be grater or equal  2");
return false;
}
}
}
 document.getElementById("caspioform").onsubmit=check;

</SCRIPT>

 

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