lmooring Posted June 21, 2017 Report Share Posted June 21, 2017 (edited) 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 June 21, 2017 by lmooring Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 29, 2017 Report Share Posted June 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
lmooring Posted June 29, 2017 Author Report Share Posted June 29, 2017 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" Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 30, 2017 Report Share Posted June 30, 2017 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> lmooring 1 Quote Link to comment Share on other sites More sharing options...
lmooring Posted July 13, 2017 Author Report Share Posted July 13, 2017 This worked perfectly, thank you so much! Quote Link to comment Share on other sites More sharing options...
Mathilda Posted July 14, 2017 Report Share Posted July 14, 2017 14 hours ago, lmooring said: This worked perfectly, thank you so much! You're welcome 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.