Validating url with jQuery without the validate-plugin?

后端 未结 7 643
情书的邮戳
情书的邮戳 2020-11-28 23:06

I need to validate a url in variable with jQuery, but can\'t use validate-plugin. Is there a simple way to do this?

相关标签:
7条回答
  • 2020-11-29 00:05

    you Want to validate your URL:

    Please pass the URL in this function then this will give you true OR false.

    See Function :

    <script>
    function isUrl(s) {
        var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
        return regexp.test(s);
    }
    
    isUrl(yourURL);
    </script>
    
    0 讨论(0)
提交回复
热议问题