Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Integrate jQuery Mask Plugin with React.js? #498

Closed
igorescobar opened this issue Dec 27, 2016 · 7 comments
Closed

How to Integrate jQuery Mask Plugin with React.js? #498

igorescobar opened this issue Dec 27, 2016 · 7 comments

Comments

@igorescobar
Copy link
Owner

I've made a simple jsfiddle showing how to integrate jQuery Mask with React.js:
https://jsfiddle.net/igorescobar/47ubm7az/

@igorescobar igorescobar changed the title How to Integrate jQuery Mask Plugin it with React.js? How to Integrate jQuery Mask Plugin with React.js? Dec 27, 2016
@rinatsafin
Copy link

not work fiidle

@duynguyenhoang
Copy link

duynguyenhoang commented Aug 28, 2018

@rinatsafin You can refer to my new example https://jsfiddle.net/nhduy88/20s9ubrv/

@wemersonrv
Copy link

Hello, to use with React, i need to install this plugin and jquery too ?

@duynguyenhoang
Copy link

Definitely yes, It is jQuery plugin.

@LuizFellype
Copy link

LuizFellype commented Apr 5, 2020

Yes, Need install and import jQuery as $ and need to import the code on top of the file, like this:

import $ from 'jquery';
import 'jquery-mask-plugin/dist/jquery.mask.min'; 

Theeennn... You can use it:

$('.dinheiro').mask('#.##0,00', {
      reverse: true,
      placeholder: '0,00'
    });

I am clarifying this because I didn't find anyone saying nothing. And just adding the script into header tag doesn't work.

@relaxdd
Copy link

relaxdd commented Apr 24, 2022

так же почему то не работает если прописать в input data-mask="..."

@Alberto-Frigatto
Copy link

  1. First you must install jquery-mask-plugin by your package manager:

NPM:

npm i jquery-mask-plugin

Bower:

bower install jquery-mask-plugin

Meteor:

meteor add igorescobar:jquery-mask-plugin

Composer:

composer require igorescobar/jquery-mask-plugin


  1. Then you will import jquery and jquery-mask-plugin in your component:
import $ from 'jquery';
import 'jquery-mask-plugin';

const Component = () => {
  $(() => {
    $('#date').mask('00/00/0000');
  });

  return (
    <form onSubmit = { e => e.preventDefault() }>
      <input
        type = 'text'
        id = 'date'
        placeholder = '00/00/0000'
      />
    </form>
  );
}

export default Component;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants