This demo demonstrates how to trigger the React MaskedInput's valuechanged and textchanged events.

React MaskedInput: Events

The events that occur in React MaskedInput.

A live React example of jqxMaskedInput, the jQWidgets MaskedInput component, with its complete source code below. It is one of 4 jqxMaskedInput demos for React.

jqxMaskedInput API used in this demo

Source code

To run it in your own app, install the package with npm install jqwidgets-scripts, add these files to a Vite React and TypeScript project, and import jqx.base.css and a theme in main.tsx. Getting started with jqxMaskedInput shows the setup step by step.

App.tsx

import type { JSX } from 'react';
import { useRef, useCallback } from 'react';
import JqxMaskedInput from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxmaskedinput';
import JqxPanel from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxpanel';

interface ChangeEventArgs {
    type: string;
    args: {
        value: string;
    };
}

function App(): JSX.Element {
    const events = useRef<JqxPanel | null>(null);

    const handleChange = useCallback((event: ChangeEventArgs) => {
        const eventType = event.type;
        const eventValue = event.args.value;
        events.current?.prepend(`<div style="margin-top: 5px;">type: ${eventType}; value: ${eventValue}</div>`);
    }, []);

    return (
        <div>
            <div style={{ fontSize: '13px', fontFamily: 'Verdana', marginTop: '10px' }}>
                Phone Number
            </div>
            <JqxMaskedInput
                theme="tailwind-blue-dark"
                style={{ marginTop: '3px' }}
                onChange={handleChange}
                width={250}
                height={25}
                mask="(###)###-####"
            />
            <div style={{ marginLeft: '0px', marginTop: '20px' }}>
                <div>
                    <span>Events:</span>
                    <JqxPanel
                        theme="tailwind-blue-dark"
                        ref={events}
                        style={{ border: 'none' }}
                        width={300}
                        height={250}
                    />
                </div>
            </div>
        </div>
    );
}

export default App;

Learn more

More React MaskedInput demos