<script> <br>function TextValidate() { <br> var code; <br>var character; <br>var err_msg = "The folder name cannot contain one of the following characters: n \ / : * ? " < > | & , "; <br>if (document.all ) <br>{ <br>code = window.event.keyCode; <br>} <br>else { <br>code = arguments.callee.caller.arguments[0].which; <br>} <br> var character = String.fromCharCode(code); <br>var txt = new RegExp("[\*,\&,\\,\/,\?,\|,\:,\<,\>, "]"); <br>if (txt.test(character)) { <br>alert(err_msg); <br>if (document.all) { <br>window.event.returnValue = false; <br> } <br>else { <br>arguments.callee.caller.arguments[0].preventDefault(); <br>} <br>} <br>} <br></script>
asp:TextBox ID="txtFolderNameEng" CssClass="frmTxt" runat="server" MaxLength="200" onkeypress="TextValidate()" >
Use the above in the onkeypress event of the textbox Just use the method.
You can limit the input of *,&,,/,?,|,<,>. If you need to limit more special symbols, just add var txt = new RegExp("[\*,\ &,\\,\/,\?,\|,\:,\<,\>,"]");
.