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

Question

Question

Masked fields bypassing the fact it's required field??

asked on March 17, 2014

So we are using in Forms 9.1 a field that is required and users must enter the last 4 digits of their SSN.  However, we've encountered an issue that if a user enters in their SSN, the deletes it, the field get's masked (even though there is no data in there since it was deleted) AND they're able to submit the form (even though it is a required field).  Thus our Template in Laserfiche is blank (because there's no data).  Is this a "bug" with Forms, or is there something wrong with the below code that would allow this?

 

$(document).ready(function () {
02    
03     $.getScript('http://formsServer/Forms/js/jquery.mask.min.js',function () {
04       $(".ssn input").mask("999-99-9999");
05       $(".ssn input").blur(function () {
06          
07         if ($(this).val() != '***-**-****') {
08         $(".filledField input").val($(this).val());
09         $(this).val('***-**-****');
10         }
11          
12       });
13     });
14 });

 

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on March 17, 2014 Show version history

It's a problem with your code. You need to handle the case where the value is blank when the user leaves the field, and you also want to make sure that, if the user leaves the field twice, their social will not be replaced by ***-**-****.

 

Try something like this:

 

$(document).ready(function () {

    $.getScript('http://formsServer/Forms/js/jquery.mask.min.js', function () {
        $(".ssn input").mask("999-99-9999");
      
       $(".ssn input").blur(function () {
        if ($(this).val() == '***-**-****') { return; }
         
        $(".filledField input").val($(this).val());
         
        if ($(this).val() == '') { return; }
		
         else if (/\d\d\d-\d\d-\d\d\d\d/.test($(this).val())) {
            $(this).val('***-**-****');
        }
    });
    });
   
});

 

1 0

Replies

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

Sign in to reply to this post.