ASP.NET正则表达式 - 不允许网站URL

时间:2018-03-08 16:47:34

标签: asp.net validation bootstrap-4

我正在使用ASP.net 4.5和bootstrap。 下面是我只允许某些字符的代码。 如何更改此设置以允许字符 a-zA-Z0-9_。 /,& |()! - 但不允许用户输入 http www。

<input type="text" class="form-control" name="subject" id="subject" placeholder="Enter subject"
                                    data-bv-message="The subject is not valid."
                                    data-bv-notempty="true" data-bv-notempty-message="The subject is required and cannot be empty."
                                    data-bv-regexp="true" data-bv-regexp-regexp="^[a-zA-Z0-9_. /,&|()!-]+$" data-bv-regexp-message="The subject can only consist of alphabetical, number, dot and underscore."
                                    />

1 个答案:

答案 0 :(得分:0)

我会说你可能不得不为你想要的输入值中的单词添加组。

((!|www)|(!|http))

你也可以看看这个answer to a similar question,你应该得到足够的输入来修复你的表达