Hi all,
i am sure its very small but i tried a lot since not a expert in c# validations
kindly help me here for validation.
1. I have two textboxs one for username, another for just email
2. i have to use CustomValidator for textbox.
the movment when cursour goes to next text box with blank(if textbox1 isempty)from first, then i want to display customvalidator error message.
Yes we have RequiredFiled validator option, it shows the msg when press the submit buttion only but not when cursor moves to next textbox.
how to display errormsg when cursor moves to next textbox like txtbox1 should not empty.
from UI.ASPX Source 
ErrorMessage=""
Display="Dynamic"
forecolor="Red"
OnServerValidate="CustomValidator1_ServerValidate"
ControlToValidate="TxtUserName"
ValidateEmptyText="True">
From UI.ASPX.cs code
protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
if (args.Value == "")
{
CustomValidator1.ErrorMessage = "error from custom";
args.IsValid = false;
}
}

Kindly help me with code for the above requirement.
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Aug 1, 2019, 5:17 AM
function validateData()
{
//write validation code here.
}
Rajanikant HawaldarPosted Aug 1, 2019, 5:13 AM