The Below snippet is my code for TextBox Float validation(its working fine)
public class textboxFloat : System.Web.UI.WebControls.TextBox
{
private const String CHECK_float_NAME = "floatValidate";
protected override void OnPreRender(System.EventArgs e)
{
StringBuilder clientScript = new StringBuilder();
base.OnPreRender(e);
clientScript.Append("<script language='javascript'>");
clientScript.Append("function " + CHECK_float_NAME + "()");
clientScript.Append("{");
clientScript.Append("if ((event.keyCode < 46) || (event.keyCode > 57) ||
(event.keyCode==47))");
clientScript.Append("event.returnValue = false;");
clientScript.Append("}");
clientScript.Append("</script>\r");
Page.RegisterClientScriptBlock(CHECK_float_NAME,
clientScript.ToString());
}
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter
writer)
{
base.AddAttributesToRender(writer);
writer.AddAttribute("onkeypress", "return " + CHECK_float_NAME + "();");
}
}
My Doubt is How to add Regular expression validators to my CS file of the
Custom Control Textbox Which ll validate EMAIL Address.
*Please Let me Know your suggestions*
--
Thanks in advance
Sarvesh