Masked Input Fields
Your form may contain fields whose values should have a specific format. To ensure that users enter values correctly, you can add input masks to these form fields. Users can click a masked input field or hover the mouse pointer over it to view the expected value format. This demo shows how to specify different input mask types. Switch between available JavaScript frameworks to view a dedicated demo version of input masking for jQuery, React, Angular, Vue.js, or Knockout. Read more...
Your form may contain fields whose values should have a specific format. To ensure that users enter values correctly, you can add input masks to these form fields. Users can click a masked input field or hover the mouse pointer over it to view the expected value format. This demo shows how to specify different input mask types. Switch between available JavaScript frameworks to view a dedicated demo version of input masking for jQuery, React, Angular, Vue.js, or Knockout.
Reference Sources
SurveyJS uses a third-party Robin Herbots Inputmask plugin for masking input fields. Reference the plugin's script on your page. You should also reference a script that integrates the SurveyJS Form Library with third-party libraries (surveyjs-widgets.js
). Open the HTML tab and copy the links from there.
Configure Input Masks
You can add input masks to Text and Multiple Text questions. To specify the input mask type, use the inputMask
property. SurveyJS supports the following mask types:
"datetime"
A date and time mask type. The default mask is"yyyy-mm-dd'T'HH:MM:ss"
. Use theinputFormat
property to change it."currency"
A currency mask type. Use theprefix
andsuffix
properties to add currency symbols before or after the value. You can also set thenumberDigits
property to change the allowed number of decimal digits (default value: 2)."decimal"
A decimal number mask type."phone"
A phone number mask type. Use theinputFormat
property to specify the mask."ip"
An IP address mask type."email"
An e-mail address mask type.
You can also specify a custom input mask that does not belong to any of the listed types. To do this, omit the inputMask
property and assign the custom mask to the inputFormat
property.