Tonie Posted March 10, 2020 Report Share Posted March 10, 2020 Hello, I am just starting with Javascript, (I do program in other languages). I am trying to capture the situation where a user does not enter either a Primary or Secondary phone. This is on a Submission page. I inspected the items and it had EditRecordPrimaryPhone on the page .I also tried InsertRecord, but nothing works. It doesn't look like the page is running the Javascript at all, and I don't know how to debug it. I added a message that I hoped I would see either way to try to check that the Javascript was running. I put the code in the Footer. Are there ways of debugging? Thanks Tonie <SCRIPT LANGUAGE="JavaScript"> function checkPhones(){ var p1 = document.getElementById("EditRecordPrimaryPhone").value; var p2 = document.getElementById("EditRecordSecondaryPhone").value; if(p1 == "" && p2 == ""){ { window.alert('Please input at least one phone number'); return false; } else { window.alert( p1 + '' + p2); return false; } } } document.getElementById("caspioform").onsubmit=checkPhones; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
cheonsa Posted March 14, 2020 Report Share Posted March 14, 2020 Hi @Tonie, If you were using a Submission Form, you must use 'InsertRecord' prefix instead of 'EditRecord'. Also, please check if the Ajax loading is enabled. You must disable it first to make your JavaScript to work. I tried this code on my end and it works as expected. <SCRIPT LANGUAGE="JavaScript"> function check() { var p1 = document.getElementById("InsertRecordPrimaryPhone").value; var p2 = document.getElementById("InsertRecordSecondaryPhone").value; if(p1 == '' & p2 == '') { window.alert('Please input at least one phone number'); return false; } else { window.alert(p1+' ' + p2); } } document.getElementById("caspioform").onsubmit=check; </SCRIPT> Hope this helps! Quote Link to comment Share on other sites More sharing options...
Tonie Posted March 15, 2020 Author Report Share Posted March 15, 2020 Thank you!!!!! I had no idea about the Ajax loading. What does that do? It works now for my submission form. The code I copied was from my update form, so I am hoping it will work there with the EditRecord . Are there any other tricks am I missing to get Javascript to work? Thank you again Quote Link to comment Share on other sites More sharing options...
AtayBalunbalunan Posted March 15, 2020 Report Share Posted March 15, 2020 AJAX is a capability that allows immediate communication between Caspio’s servers and deployed DataPages, so users can easily interact with applications without reloading the entire web page. AJAX loading provides a superior user experience and performance of common interactions such as data submission, sorting, paging and refreshing results pages with new criteria. For applications with multiple DataPages deployed on the same web page, the data will automatically refresh across all DataPages when users interact with the application. To know more, please refer to https://howto.caspio.com/datapages/ajax-loading/. Quote Link to comment Share on other sites More sharing options...
AtayBalunbalunan Posted March 15, 2020 Report Share Posted March 15, 2020 You can refer to this guideline for referencing Caspio form elements using JavaScript. You can also find some JavaScript solutions here: https://forums.caspio.com/forum/49-caspio-javascript-solutions/ 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.