JS Check for URL code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags .url ajax authentication check code domain ftp function

JS Check for URL code


in a lot of time to check whether for the URL code, verify that the URL is the correct format Oh, the following provides a JS authentication URL function, he can verify the HTTPS tutorial |http|ftp|rtsp|mms, there are ports.


** 


* Check for URL


    * 


* @param {}


* Str_url


* @return {Boolean} true: URL,false:<b> not </b> URL;


    */ 


This.isurl = function (Str_url) {//Verify URL


var Strregex = "^ (HTTPS|HTTP|FTP|RTSP|MMS)?:/ /)" 


                + "? ([0-9a-z_!~* ' (). &=+$%-]+:)? [0-9a-z_!~* ' (). &=+$%-]+@)? " FTP user@


+ "([0-9]{1,3}.) {3} [0-9] {1,3} "//IP form of url-199.194.52.184


+ "|"//Allow IP and domain (domains)


+ "([0-9a-z_!~* ' ()-]+.)   * "//Domain name-www."


+ "([0-9a-z][0-9a-z-]{0,61})? [0-9a-z]. Level two domain


+ "[a-z]{2,6}]"//domain-. com or. Museum


+ "(: [0-9]{1,4})"//Port-: 80


+ "((/?)|" A slash isn ' t required if there is no file name


+ "(/[0-9a-z_!~* ' ();?: @&=+$,%#-]+) +/?)   $";


var re = new RegExp (Strregex);


return Re.test (Str_url);


    } 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.