---
title: Inputmask
product: Form Library
description: Inputmask | JS Survey and Form Library Example for JavaScript
framework: jQuery
source: https://surveyjs.io/form-library/examples/control-data-entry-formats-with-input-masks/jquery
index: https://surveyjs.io/form-library/examples/overview.md
---

# Inputmask (jQuery)

## Files

### `public/index.html`

```html
<link href="https://fonts.googleapis.com/css?family=Open%20Sans:400,600&display=swap" rel="stylesheet">
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import $ from "jquery";
import { Model } from "survey-core";
import "survey-js-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";
import * as SurveyCore from "survey-core";
import Inputmask from "inputmask";
import { inputmask } from "surveyjs-widgets";

inputmask(SurveyCore);
const survey = new Model(json);
survey.onComplete.add((sender, options) => {
    console.log(JSON.stringify(sender.data, null, 3));
});

$("#surveyElement").Survey({ model: survey });
```

### `src/json.js`

```js
export const json = {
   "elements": [
      {
         "type": "html",
         "name": "obsoleteMsg",
         "html": "<p>This example is obsolete. SurveyJS Form Library now offers the functionality of Inputmask out of the box. Please refer to the following example instead: <a href='https://surveyjs.io/form-library/examples/masked-input-fields/'>Masked Input Fields</a>.<p>"
      },
      {
         "name": "date",
         "type": "text",
         "title": "Date:",
         "inputMask": "datetime",
         "inputFormat": "mm/dd/yyyy"
      },
      {
         "name": "currency",
         "type": "text",
         "title": "Currency:",
         "inputMask": "currency",
         "prefix": "$",
         "numericDigits": 2,
         "startWithNewLine": false
      },
      {
         "name": "decimal",
         "type": "text",
         "title": "Decimal:",
         "inputMask": "decimal"
      },
      {
         "name": "phone",
         "type": "text",
         "title": "Phone:",
         "inputMask": "phone",
         "inputFormat": "+9(999)-999-99-99",
         "startWithNewLine": false
      },
      {
         "name": "ip",
         "type": "text",
         "title": "IP address:",
         "inputMask": "ip"
      },
      {
         "name": "email",
         "type": "text",
         "title": "Email address:",
         "inputMask": "email",
         "startWithNewLine": false
      }, {
         "name": "creditcard",
         "type": "text",
         "title": "Custom format",
         "description": "Enter a credit card number",
         "inputFormat": "9999 9999 9999 9999"
      }
   ],
   "questionTitleLocation": "left"
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "jquery": "latest",
    "inputmask": "5.0.3",
    "surveyjs-widgets": "latest",
    "survey-core": "latest",
    "survey-js-ui": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/control-data-entry-formats-with-input-masks/angular.md)
- [React](https://surveyjs.io/form-library/examples/control-data-entry-formats-with-input-masks/reactjs.md)
- [Vue 3](https://surveyjs.io/form-library/examples/control-data-entry-formats-with-input-masks/vue3js.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/control-data-entry-formats-with-input-masks/vanillajs.md)
