Sudesh Posted September 26, 2017 Report Share Posted September 26, 2017 Hi I am new to caspio, JS. I have a attendee checkin screen. I need to validate attendee by entering least on to the validation values to make sure the right person is checkedin. I have 3 validation values, code sent at the time of registration, mobile number and email. I have setup an update for with 3 virtual fields and modified a JS function I found on this forum to check if atleast on of the field is entered and then to check the enter field is same as on record. For some reason the fucntion never get call when I click the update button. below is the code. Really appreciate if someone can point what I am missing/doing wrong. Thanks in advance for your help. <script language="Javascript"> function myFunction() { var field_code = document.getElementById("cbParamVirtual1").value; var field_email = document.getElementById("cbParamVirtual2").value; var field_phone = document.getElementById("cbParamVirtual3").value; if (field_code == "" && field_phone == "" && field_email == ""){ alert("Please enter at least one verification value. Please try again."); return false; } else if ( field_code !== "") { If (field_code !== [@field:ER_CODE]{ alert("Attendee Code did not match. Please try again."); return false; } } else if (field_phone !== "") { If (field_phone !== [@field:Phone#]{ alert("Attendee Phone number did not match. Please try again."); return false; } } else if (field_email !== "") { if (field_email !== [@field:Email]) { alert("Attendee Email did not match. Please try again."); return false; } } } document.getElementById("caspioform"). Mod0EditRecord = myFunction; </script> Quote Link to comment Share on other sites More sharing options...
douvega Posted September 29, 2017 Report Share Posted September 29, 2017 Hi Sudesh, Since you say you are new in Caspio JS, I would recommend you using a Details Page type for this. This will provide you a Seach page which you can use to validate those fields with minimal JS coding. If results are found, then you can redirect people accordingly or you can show a good looking message telling the parameters are not correct. Plus, for the phone number validation, you may face issues as phone formats are variable depending on the user and that is out of our control unless you format the number when it is entered the first time and it is typed on this search/validation page. In case you need help doing it, you can visit https://www.futuresuite.net and I will be more than happy to assist you. Quote Link to comment Share on other sites More sharing options...
futurist Posted November 20, 2023 Report Share Posted November 20, 2023 Just to add, if you also wish to validate value entered in an input field to make sure that it follows this format: www.websitename.com Then you can use this code: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { var inputField = document.querySelector('#InsertRecordNameofField'); const value = inputField.value; const regex = /^www\.[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$/; if (!regex.test(value)) { event.preventDefault(); alert('Invalid Submission!'); } else { document.form["caspioform"].submit(); } }); </script> Make sure to replace "NameofField" with the actual name of the field that you want to validate before submitting. 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.