Skip to content
Advertisement

Show JS alert on a form php

I have the following php code, which is a wordpress hook to display an address autocomplete form on my website’s cart page.

JavaScript

The function was written in functions.php file. I dont want the customer’s to enter their unit numbers or house numbers. As such, I want to display a simple js alert if a customer enters “/” charachter in the input field. What would be the best approach to do this?

Advertisement

Answer

Use HTML attribute: pattern

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement