Validate remote url using javascript

1. Read remote url. var url ='<!--#echo var="REMOTE_HOST"-->'; 2. Enter list of additional url var additional_url = ["http://www.abc.com"]; 3. Create a regular expression string. var handleurl = additional_url.join("|"); handleurl = new RegExp(handleurl, "i"); 4. Check condition whether remote url is in list if (url.search(handleurl)!=-1) alert("done") else alert("Unauthorized access");

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>

More information about formatting options