如何使用javascript验证网站网址 [英] how to validate web site url using javascript

查看:76
本文介绍了如何使用javascript验证网站网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我想使用javascript acn进行网站url验证,然后发送任何代码段或准则

hello,
I want web site url validation using javascript acn u send any snippets or guide lines

推荐答案


您可以使用正则表达式
Hi ,
you can use regularexpression
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"

    ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="Error"

    ForeColor="#FF3300" SetFocusOnError="True"

    ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?"

    ValidationGroup="yourgroup"></asp:RegularExpressionValidator>


最好的问候
M.Mitwalli


Best Regards
M.Mitwalli




请尝试以下链接:


http://snippets.dzone.com/posts/show/452 [ http://forums.digitalpoint.com/showthread.php?t=242636 [ ^ ]


http://www.456bereastreet.com/archive/201105/validate_url_syntax_with_javascript/ [
Hi,

Please try following links:


http://snippets.dzone.com/posts/show/452[^]


http://forums.digitalpoint.com/showthread.php?t=242636[^]


http://www.456bereastreet.com/archive/201105/validate_url_syntax_with_javascript/[^]


var s = window.location.host
if(s.indexOf("www.mywebsite.com") == -1)
{
      //the url is not mine so do what need to be done.
}


这篇关于如何使用javascript验证网站网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆