Jump to content
  • 0

Java If Then Help Needed


braxwell

Question

Hi - I have a reports page that I need to add a simple script to that will look at the values of two fields - and if those values are equal - will display a message and prevent submission.

I think and If then statement would work but i'm not able to write it myself.

Can anyone help with that script?

 

Thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @braxwell,

If you are using a submission form/DataPage, you can use the code below and just put it in the footer of your submission form/DataPage. 

You will just need to update the ID in the code below, to the ID of your fields using the browser developer tools. For more details about this, you can check this article: https://support.softools.net/hc/en-gb/community/posts/115001929071-Find-the-Field-ID-with-Browser-Developer-Tools

<script>

document.querySelector('#caspioform').onsubmit = function(e) {
    e.preventDefault();
// Replaced the ID in the code below 'InsertRecordValue1' to the ID of your fields
  
var input1= document.getElementById("InsertRecordValue1").value;
var input2= document.getElementById("InsertRecordValue2").value;

if (input1 === input2 ){
alert('You cannot have the same value for two fields!');
} 

else {
this.submit();

}

}

</script>

 

If this is not a Submission form, kindly elaborate on your workflow.

I hope this helps.

Regards,

TsiBiru

Link to comment
Share on other sites

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.

Guest
Answer this question...

×   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.

Loading...
×
×
  • Create New...