如何限制HTML元素,让别人 [英] how to restrict HTML elements while allowing others

查看:79
本文介绍了如何限制HTML元素,让别人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何只允许某些HTML标签的文本框中

How to only allow certain html tags in a text box

例如:

    <Strong>
    <p>

在code以下是我一直在努力实现创建类的解决方案。

The code below is where I have been trying to implement the solution in a class created.

[Required]
(Code)
Public string car { get; set; }

我将如何着手实施解决方案,并有可能在哪里(code)上面写了点。

How would I go about implementing the solution and is it possible at the point where (code) is written above.

推荐答案

下面的正前pression只允许指定的HTML标签:

The following Regular Expression allows only the Html tags specified:

[RegularExpression(@"^([^<]|<p>|</p>|<strong>|</strong>|a z|A Z|1 9|(.\.))*$")}

这允许HTML &LT; P&GT; &所述; / P&GT; &LT;强&GT; &LT;要同时不允许任何其他标​​记输入; / STRONG&GT。

This allows for the html <p> </p> <strong> </strong> to be entered while not allowing any other tags.

添加其它标签(如果需要)。

Add other tags if required.

这篇关于如何限制HTML元素,让别人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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