You are viewing limited content. For full access, please sign in.

Question

Question

Can JavaScript be used to show a message if someone enters the wrong answer in a field?

asked on December 14, 2022

I have too many people with typos in their email address in a field on a form.  These are not licensed users so I can't have their email addresses in a lookup.  

The majority of the email addresses will end with @flagstaff.ab.ca and the majority of the errors are in the spelling of flagstaff. 

Can JavaScript be used to validate that portion of the address and if it is not spelled right, cause a popup window to warn them about it?

0 0

Replies

replied on December 14, 2022

Yes. If you're using the classic designer you could do it several different ways, but things get a lot more complicated if not all end in the same domain because you'd basically have to code a check for every possible misspelling.

You could trigger javascript on the change event. The only thing there is that it wouldn't necessarily prevent submission so they could just dismiss it and submit without fixing the issue.

You could switch from an email field to a single line and use regex to look for the desired domain. This would only really be an option if the domain is always predictable.

You could also use a custom validator to check the domain. This would also prevent submission if there's an issue, but again it depends on predictable domains or coding every misspelling.

2 0
replied on December 14, 2022

What about a generic message that would activate every time someone enters an email address in that field.  The message would simply say something like "please check your address for accuracy".  That might simplify things, right?

So, what would that JavaScript look like?

0 0
replied on December 14, 2022

It depends on exactly what you want to do. Another option would be to make them enter it twice with a confirmation field and check if they match. That can help, but even then, people will still make mistakes.

Based on my experience, a popup message/window is just going to get ignored by the people most likely to make those kinds of mistakes so it tends to just become a nuisance for everyone else.

A "no code" option if you just want a message would be to add a Custom HTML element with some attention-grabbing styling, then have a field rule set to show it when the email field isn't empty.

2 0
replied on December 14, 2022

I'm not sure what the Custom HTML option you're suggesting would look like.

Another idea I just came up with would be to have a look up fill a single line field with the most common endings that they can pick from and then just add their first part.

A picklist like:

  • flagstaff.ab.ca
  • gmail.com
  • hotmail.com
0 0
replied on December 14, 2022

That's a possibility. You could have a hidden field that uses a calculation/formula to combine the two pieces, but that may not be intuitive for the user since it's not very common to split the email that way.

 

The Custom HTML would just be adding a Custom HTML item to the form from the field menu, typing in your message, and styling it with CSS to make it bold, red, larger font, or whatever you want.

Then you just set a Field Rule like you would with any other field.

2 0
replied on December 14, 2022

Ah, got it.  Thanks, Jason.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.