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

Question

Question

Check Asterisk "*" Value on Submit

asked on March 22, 2018

I have a field that users can put in an asterisk for a wildcard, however, I do not want them to use a single wildcard. If they do, I want to throw an error. Here's what I have, but it's not working:

$(document).ready(function(){

//A single * in the Project # field is NOT ALLOWED
  $('.Submit').click(function() {    
    if($('.projectNo').val() == '*')
    {
       alert('A single asterisk "*" is not allowed in the Project # field!');
    }
  });

});  //close document.ready

What am I doing wrong?

0 0

Answer

SELECTED ANSWER
replied on March 22, 2018 Show version history

Add the word "input" in your code like this

 

if($('.projectNo input').val() == '*')

 

0 0
replied on March 22, 2018

Funny, was thinking of putting a 3-character minimum limit on the field. What would that look like?

Replies

replied on March 22, 2018

You could also try just a regex on the field,  ^([^\*]|.{2,})$   That should allow anything but a single *

1 0
replied on March 22, 2018

Funny, was thinking of putting a 3-character minimum limit on the field. What would that look like?

0 0
replied on March 22, 2018

Just to check for a min of 3 chars,    .{3,}

1 0
replied on March 22, 2018

So I ended up going with a 5-xter min and 100-xter max. Thanks for the help!!!

((?=.*([A-Za-z0-9-/]+)).{5,100})

2 0
replied on March 22, 2018

Thank you, Raul! I knew it would be something silly.

0 0
replied on April 11, 2019

Is this a way I can put a minimum word count in a multi line field? for example: we have a multi line field where an applicant needs to submit an essay. We request the essay to be a minimum of 150 words.... any input would help! thanks

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

Sign in to reply to this post.