tags:

views:

37

answers:

3

I have designed a page where user can write messages and send within a group but i want that if they enter any special character like <>?#@ etc a msg should be displayed irrespective of the crashing of the page.

Can anyone help me out???

+1  A: 

You have 2 possibilities for doing that.

A) You are adding a regularexpression validator to each control B) You use a customvalidator which you can bind to each control too

First solution is the better one for you.

How you do it? See here: http://www.codeproject.com/KB/validation/aspnetvalidation.aspx

MUG4N
+1  A: 

It's not reccommended but you can use ValidateRequest="false" in the page declaration to allow values like that to be sucessfully posted back.

e.g. <%@ Page Title="" Language="C#" ValidateRequest="false"..

Brissles
A: 

for that you have to use javaScript validation or any server site validation for javaScript function validate(inputText) { if(inputText.match(/[<>]/)) return false; } function TextBoxValidate() { var txt1=document.getElementById(TextBoxId).value; if(!(validate(inputText))) { alert("incorrect text") return false; } else return true; }

call these function in that text box where you want to validate by using onClientClick="return TextBoxValidate();"