rgiljohann Posted September 21, 2018 Report Share Posted September 21, 2018 I have used the forum to get to this point so you may have seen some of my code that I grabbed from other posts. I have a single record update form, where I only want them to be able to select the update button if all of the fields are marked as 'complete'. It should be known that all of the 'complete' or 'missing data' fields are formulas in the table, however, I am referencing virtual fields in my code that are set to the formula fields. The url to my form is here: https://c5amf675.caspio.com/dp/32576000f879393a309d4a97b1bd My code for checking the virtual field values is here: <script language="JavaScript"> function check_numbers() { var disabled = false; if (parseFloat(document.getElementById("cbParamVirtual").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtua2").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual3").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual4").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual5").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual6").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual7").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual8").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual9").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual10").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual11").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual12").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual13").value)=='Complete') disabled = true; if (parseFloat(document.getElementById("cbParamVirtual14").value)=='Complete') disabled = true; if (disabled) { alert("All fields must be complete"); return false; } } document.getElementById("caspioform").onsubmit=check_numbers; </script> What is really weird, is that even the following code will not show a message when I click on the update button. <SCRIPT LANGUAGE="JavaScript"> function check() { window.alert("Thank you.. Information is registered!"); } document.getElementById("caspioform").onsubmit=check; </SCRIPT> I tried this small alert function after I couldn't get my regular code to work. This was on its own and did not work. I am thinking that there is an issue somewhere where the onclick is not registering. Do any of you have any idea what might be the problem? Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted September 27, 2018 Report Share Posted September 27, 2018 Hi @rgiljohann Please note that Caspio form does not support on load event handlers and you need to use Caspio built-in event handlers. The onload event should be replaced with Caspio built-in event as shown below: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { // do something }); </script> You can find more details in this article: https://howto.caspio.com/deployment/ Hope this helps. Regards, Vitalikssssss Quote Link to comment Share on other sites More sharing options...
rgiljohann Posted September 27, 2018 Author Report Share Posted September 27, 2018 Hello, thanks for the response. I tried the function below. cbParamVirtual13 right now is set to Missing Data, but it still allowed me to click update and everything worked. <script type="text/javascript"> function f_submit() { if (parseFloat(document.getElementById("cbParamVirtual13").value)=='Complete') { document.getElementById("caspioform").update(); } else if (parseFloat(document.getElementById("cbParamVirtual13").value)=='Missing Data') { window.alert("You are missing data"); } document.addEventListener('DataPageReady',f_submit); </script> Quote Link to comment Share on other sites More sharing options...
Volomeister Posted June 22, 2022 Report Share Posted June 22, 2022 Hi rgiljohann. Not sure if this still actual thread. You can use parseFloat to convert a number-like string (e.g. "1.44" or "3123.3221" etc.) into a number. You are trying to convert 'Missing Data' into a number, which will return NaN, and then compare it with a string, so it will never return true, therefore window.alert("You are missing data") statement will never be executed. So you do not need to wrap document.getElementById("cbParamVirtual13").value into parseFloat before comparing it with 'Missing Data' 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.