Skip to content

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

Closed

Description

@igorescobar

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

Activity

  1. changed the title [-]How to Integrate jQuery Mask Plugin it with React.js?[/-] [+]How to Integrate jQuery Mask Plugin with React.js?[/+] on Dec 27, 2016
  2. rinatsafin commented on Aug 13, 2018

    @rinatsafin

    not work fiidle

  3. duynguyenhoang commented on Aug 28, 2018

    @duynguyenhoang

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

  4. wemersonrv commented on Dec 30, 2018

    @wemersonrv

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

  5. duynguyenhoang commented on Jan 2, 2019

    @duynguyenhoang

    Definitely yes, It is jQuery plugin.

  6. LuizFellype commented on Apr 5, 2020

    @LuizFellype

    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.

  7. relaxdd commented on Apr 24, 2022

    @relaxdd

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

  8. Alberto-Frigatto commented on Dec 22, 2022

    @Alberto-Frigatto
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions