Here is how you can apply some forced formatting to an Order Form field or custom Payment method, for example, a phone number or an account number.
Add the script below to your form and replace udf_FIELDNAME with the name of your field.
Below is an example of that being used, I can only type numbers and only in a specific format.
For Payment methods, this is slightly more complex and you need the CSS selector of the payment method. To find this use the inspect tool on your browser, below is an example.