I have created a url field and submit button.and i want to validate this url like that it will show .xml regular expression at the end of url instead of .com and anything else. I have tried this code but didn't get reliable solution.It's redirecting me on another page when i writes invalid url.
Please help me through this . Any help will be appreciated.
Thanks in advance.
function validateURL(){
var re = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/.xml;
if (!re.test(url)) {
alert("url error");
document.getElementById("error_msg").innerHTML = "invalid url";
return false;
}
}