import InputHandler from "./components/InputHandler"; jQuery(document).ready(function ($) { /** * Initialize an InputHandler instance for handling input and validation * for both the address field and house number field. */ const inputHandler = new InputHandler( "#billing_address_1", // Selector for the address field "#billing_housenumber", // Selector for the house number field ); /** * Set up input event listeners for the billing address and house number fields. * The `handleInput` method of the InputHandler instance is called when the input changes. */ jQuery("#billing_address_1").on("input", (e: JQuery.TriggeredEvent) => { // Cast the event to InputEvent for handleInput method inputHandler.handleInput(e.originalEvent as InputEvent); }); jQuery("#billing_housenumber").on("input", (e: JQuery.TriggeredEvent) => { // Cast the event to InputEvent for handleInput method inputHandler.handleInput(e.originalEvent as InputEvent); }); /** * Block the user from pasting content into the address or house number fields. * This helps ensure data consistency and enforces the formatting rules. */ jQuery("#billing_address_1").on("paste", function (event) { event.preventDefault(); // Prevent the paste action }); jQuery("#billing_housenumber").on("paste", function (event) { event.preventDefault(); // Prevent the paste action }); });