Ronan Posted December 3, 2018 Report Share Posted December 3, 2018 Hi I'm new here, I have a submission form with 4 field / text field. What I want is the form will not be submitted when all the field is blank, but if at least one of them has value the submission will go through. If I make these fields as required in my datapage, then I have to provide values to all of this field. Which will not work for me, because I just want to have at least one field that has value so that the submission will go through. Thank you for your help Thanks Eruel Quote Link to comment Share on other sites More sharing options...
TsiBiRu Posted December 3, 2018 Report Share Posted December 3, 2018 Hello Azriel. I have similar validation in my App, I have used the JavaScript below to implement this validation. <script type= "text/javascript" > var input1 = document.querySelector('#InsertRecordValue1'); var input2 = document.querySelector('#InsertRecordValue2'); var input3 = document.querySelector('#InsertRecordValue3'); var input4 = document.querySelector('#InsertRecordValue4'); document.querySelector('#caspioform').onsubmit = function(e) { e.preventDefault(); if (input1.value.length > 0){ this.submit(); } else if (input2.value.length > 0){ this.submit(); } else if (input3.value.length > 0){ this.submit(); } else if (input4.value.length > 0){ this.submit(); } else { alert('Please fill at least one field to continue'); input.focus(); } } </script> If the code above will not work, you will need to change the '#InsertRecordValue' on the top most part of the code to the name of your field in your DataPage. To see that, just do the steps below. 1. Go to the preview of your DataPage 2. Press F12 on your keyboard, a form should be display. This is the browser developer console 3. Press Ctrl + Shift + C on your keyboard, then hover over your text field. You should be able to see its element ID, then click on this field. 4. You should be redirected to its code, just double click the id of this element. Then paste it on the JavaScript above to update it. Hope this help, if you are having an error making the code above work. Just provide me the URL of your datapage or web page and I will update it for you Regards Azriel and Ronan 2 Quote Link to comment Share on other sites More sharing options...
Ronan Posted December 3, 2018 Author Report Share Posted December 3, 2018 Hi @TsiBiRu, It worked!, I've changed the value of the query selector ('#InsertRecordV alue1') to the name of my text in my DataPage. Thank you so much for this solution. Regards, Eruel Quote Link to comment Share on other sites More sharing options...
Prateek6 Posted October 10, 2022 Report Share Posted October 10, 2022 On 12/4/2018 at 12:08 AM, TsiBiRu said: caspioform My form is not submitting and returning any value. Validation is working fine Quote Link to comment Share on other sites More sharing options...
Queso Posted October 10, 2022 Report Share Posted October 10, 2022 Hi @Prateek6, I am also curious... maybe you can attach an exported copy of your DataPage with its dependencies so we can check the current setup? Or, maybe you have another script on your form like this one: 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.