Jump to content

Form Validation, at least one field has value

Recommended Posts

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




Link to comment
Share on other sites

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) {


if (input1.value.length > 0){



else if (input2.value.length > 0){



else if (input3.value.length > 0){



else if (input4.value.length > 0){



else {

alert('Please fill at least one field to continue');





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




Link to comment
Share on other sites

  • 3 years later...

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...