by using custom validator to validate an regular expression with email id how to write a code in OnServerValidate propertie anybody can help me to solve please................
below of my code is:
Client Side Javascript:
function ValidateEmailId(source, args) {
var rdbemailid = document.getElementById("<%=rdb_No.ClientID %>");
var emilid = $("#<%= txtEmail.ClientID %>").val();
if (rdbemailid.checked) {
if (emilid == "") {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
}
Sanjeeb LenkaPosted Jun 5, 2013, 10:30 AM
manjula dPosted Jun 5, 2013, 5:59 AM
Sanjeeb LenkaPosted Jun 4, 2013, 3:29 PM
i written below code according to your requirement plz chek this
and below .cs code
using System.Configuration;
public partial class Custom_validator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ServerValidate(object source, ServerValidateEventArgs args)
{
RegexStringValidator r = new RegexStringValidator(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
try
{
r.Validate(args.Value);
args.IsValid = true;
}
catch (ArgumentException ee)
{
ee.Message.ToString();
args.IsValid = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
}
}
}
plz check this and reply
manjula dPosted Jun 4, 2013, 12:13 AM
but i want to use customvalidator only how to generate OnServerValidate propertie by using regular expression with emailid
Kiresh GangariyaPosted Jun 3, 2013, 6:21 AM
if (emailid == null || x == "") {
document.getElementById("LabelValidateEmail").innerHTML = "Email Required";
count++;
}
else {
alphaExp = /^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/; //regular expression of a valid email address
if (!x.match(alphaExp)) {
document.getElementById("LabelValidateEmail").innerHTML = "Check the Email format";
count++;
} else {
document.getElementById("LabelValidateEmail").innerHTML = "";
}