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

Question

Question

Auto correct a field

asked on February 18, 2016

We have SSN field that already has the regular expression of the format we are looking for: ###-##-####

 

Is there a way to let users type out 9 digit number and then add dashes?

 

Similarily, is there a way for Forms to auto-capitalize the first letter in first names and last names?

 

Thank you!

0 0

Answer

SELECTED ANSWER
replied on February 18, 2016

You can use the masked input jquery plugin from here to handle the SSN field. For the Name field where you want to title case the string, you can use the example from here.

In your form, make sure SSN field uses the CSS class name, ssn. For the Name field, give it the CSS class name, titlecase. Download the jquery.maskedinput.min.js file from the first link and place it in the C:\Program Files\Laserfiche\Laserfiche Forms\Forms\js folder (or someplace else if you prefer). Then you can use the following javascript

$(document).ready(function () {
  
  $.getScript('http://server/Forms/js/jquery.maskedinput.min.js', function() {
    $('.ssn input').mask("999-99-9999");
  });
  
  $('.titlecase input').on('change', function() {
    var str = $(this).val().replace(/\b\w+/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    $('.titlecase input').val(str); 
  });
  
});
1 0
replied on February 19, 2016

Thank you so much - this is exactly what I needed! 

 

This is what I ended up using, not that there are two titlecases because if you only have one but want to use it for multiple fields- it will auto-populate your previous one:

$(document).ready(function () {
  
  $.getScript('https://myservername.domain/Forms/js/jquery.maskedinput.min.js', function() {
    $('.ssn input').mask("999-99-9999");
  });
  
  $('.titlecase input').on('change', function() {
    var str = $(this).val().replace(/\b\w+/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    $('.titlecase input').val(str); 
  });
  
  $('.titlecase2 input').on('change', function() {
    var str = $(this).val().replace(/\b\w+/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    $('.titlecase2 input').val(str); 
  });
 
  $.getScript('https://lfforms.okwu.edu/Forms/js/jquery.maskedinput.min.js', function() {
    $('.phone input').mask("999-999-9999");
  });
  
});

 

0 0
replied on March 20, 2018

Hey Alex, 

The link provided for the masked input jquery plugin from here is not working. Can you please provide an updated link to get this?

Thank You,

Zach Merrill

http://digitalbush.com/projects/masked-input-plugin/

0 0
replied on March 20, 2018

@████████ Even if it's not exactly the same as the one in the dead link, I've had really good results with this library.

1 0
replied on March 20, 2018

Thanks Andy. That worked for the SSN mask!  How can I use the other mask such as Telephone with code Area? Here is the code I used for the SSN mask.

$("document").ready(function () {
$.getScript('http://Server/Forms/js/jQuery-Mask-Plugin-master\src\jquery.mask', function () {
$(".ssn input").mask("999-99-9999");
});

 

0 0
replied on March 20, 2018

They have a pretty good documentation page on that site of how to use the library; you adjust how the mask works for another class or element by changing the "999-99-9999" in your example to something else. For a phone number, you'd apply a mask with "(000) 000-0000", for instance. 

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