Jump to content
  • 0

Reject specific word entered into a field in a submission form


DaveC2019

Question

9 answers to this question

Recommended Posts

  • 0

I'm not the best at JavaScript, but I'll give it a shot. If it doesn't work, maybe someone can build upon it. 

<script>
document.querySelector('#caspioform').onsubmit = function(u) {
    u.preventDefault();

var username = document.getElementsById('ID_Of_Element')[0].value;

if (username === "@tippytv") {
  alert('Username Not Valid');
} else {
  this.submit();
}
}
</script>

Add this to the footer of the page.

Link to comment
Share on other sites

  • 0

I apologize, but there is one bit of information I forgot to include in my question and I have added it here:

I have a submission form that has a field called "username". My goal is to display an error message when the following is entered "*@tippytv". How can this be accomplished? Please not the asterisk is a wildcard and can be any word or number. 

 

Link to comment
Share on other sites

  • 0

Hello @DaveC2019

I came upon this forum thread and tweak the code of @kpcollier. Can you test if the code works for you?

Here it is:

<script>

document.addEventListener('BeforeFormSubmit', function(e) {
e.preventDefault();
var username = document.getElementById('InsertRecordName').value;

if (username == "@tippytv") {

alert('The Username is invalid!');

} else {

this.submit();

}

})

</script>

 

Let me know if this helps.

 

~ H

Link to comment
Share on other sites

  • 0
On 4/22/2019 at 8:08 AM, kpcollier said:

I'm not the best at JavaScript, but I'll give it a shot. If it doesn't work, maybe someone can build upon it. 


<script>
document.querySelector('#caspioform').onsubmit = function(u) {
    u.preventDefault();

var username = document.getElementsById('ID_Of_Element')[0].value;

if (username === "@tippytv") {
  alert('Username Not Valid');
} else {
  this.submit();
}
}
</script>

Add this to the footer of the page.

 

For some reason, this code is not working on my end. However, it seems to me that the logic is correct. Any thoughts?

Link to comment
Share on other sites

  • 0

You could use triggered actions to look for a string that replaces fields contents bases on contains. This method would update the value in the table which you could display on the confirmation page.

KEYWORD_1 = @tippytv value

KEYWORD_2 = Replaced error message value

If you need the value to be displayed to user on the datapage, you could create a rule that runs when field contains the keyword, by hiding a section with HTML block message when field does not contain keyword.

 

image.png.9de6259f78fa9392d01f2f440231df66.png

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