Last active
August 17, 2019 17:26
-
-
Save sungraizfaryad/6850b4947b15b15edbd93969726d7a9d to your computer and use it in GitHub Desktop.
You can use these methods to block any email extension and it can also prevent users to add URL in textarea field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Block ru extention in email like www.google.ru | |
| $.validator.addMethod("noRu", function(value, element) { | |
| return (this.optional(element) || value.slice(-3) != ".ru"); | |
| }, "The .ru extention is not allowed in email address"); | |
| // Prevent users to add any URL in textarea | |
| $.validator.addMethod("noUrl", function(value, element) { | |
| return (this.optional(element) || value.match(/\b(http|https)?(:\/\/)?(\S*)\.(\w{2,4})(.*)/g) == null); | |
| }, "URL is not allowed"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment