Ala Ala - 3 months ago 11
HTML Question

Display </ in a validation message

I have a regular expression attribute to validate the user input against

</
. So if the user enters
</
in the input, then the following message should be displayed:
The following value is not allowed (

but the output is displayed like this:

<span id="CurrentPassword-error">The following values are not allowed (<!--)--></span>


I have used HTML.Decode and HTML.Encode and HTML.Raw but the same result.

enter image description here

Answer

You can use an HTML encoder for special characters: < = &lt; > = &gt;

<span id="CurrentPassword-error">The following values are not allowed (&lt;!--)--&gt;</span>

Comments