How to jQuery Form Validation to Restrict Multiple URL

0 154

In jQuery, it is very simple to restrict the user to enter more than one URL via a form input. By validating this, we can avoid spam content with more hyperlinks.

In the previous tutorial, we have seen the jQuery example to validate contact form. In this tutorial, we are using jQuery match() to check the number of URL occurrences. For this jQuery function, we are passing a regex pattern to find URL match among input string.

HTML Text-Area Input

This code shows HTML text area input to the user. After entering text data, the jQuery regex match will be called to check URL occurrences.

jQuery URL Match

The jQuery regex match function will return the number of URLs entered by the user. We are checking for the URLs starts with HTTP://, https:// or FTP://. If the count exceeds 1 then this code will return an error message.

 

You might also like More from author

Leave A Reply

Your email address will not be published.