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

Question

Question

jQuery Mask only works on first row of a table - Forms 10.1

asked on March 7, 2017 Show version history

I am using a jQuery Mask on one column of a table and it works perfectly on the first row, but not on any additional rows that are added. The additional rows will report "Invalid Input" if you enter data that does not fit the pattern (so the regular expression portion is working), but it does not put the data into the mask format like it does in the first row.

Is there any way to get it to apply the mask to additional rows in a table?

Thanks - Jim

0 0

Answer

SELECTED ANSWER
replied on March 8, 2017

You need to re-apply the mask to the new inputs that appear when you click the link to add a new table row. Here's a brief example of masking a phone number in a single line field in a table where the submitter can add more rows:

$(document).ready(function () {
  $.getScript('http://server/Forms/js/jquery.mask.min.js', function () {
    $('.phone input').mask("(999)999-9999");
    $('.cf-table-add-row').click(function(){
      $('.phone input').mask("(999)999-9999");
    });
  });
});
0 0
replied on March 8, 2017

Brilliant, Alexander - this did exactly what I needed! Thanks for your assistance.

0 0

Replies

replied on March 7, 2017

Hi Jim

Suggest you copy you JSQuery code in question here for others to review. Usually find that gets quicker/better responses.

0 0
replied on March 8, 2017

Thanks for the reply Steve, but I think the issue here is that a table is involved.

I have followed the code and instructions from the Using Regular Expressions With Field Masks help page and it is working perfectly on the first row of the table. Since the table was set to Range of Rows, I tested by changing it to Fixed Number of Rows, and when set that way the mask DOES work on all rows; however when set to Range of Rows, it only works on the first row, and any added rows do not apply the mask.

Due to the requirements of this form, I would much rather use Range of Rows in this table, so I'm wondering if there is a way to alter the code so that it will work in this scenario.  

Thanks - Jim

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

Sign in to reply to this post.