Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Is it possible to display Validation controls error message through javascript alert
and i want to hide to display Errormessage in webform.


please any body advise me.

Thanks
Uday
Posted

yes, it is possible. assisn same validationGroup to all validators. then use validation summary and set ShowMessageBox property to True
here is example[^]
 
Share this answer
 
As your question is not clear enough, I can give you a certain answer.

However, take a look here and see if you find any useful information:

http://msdn.microsoft.com/en-us/library/aa479045.aspx#aspplusvalid_clientside[^]

Cheers!
 
Share this answer
 
Instead of using validation controls you can directly go for validation using javascript.

JavaScript
function validate()
{

if(document.getElementById("name").value="")
{
alert("Name is required");
document.getElementById("name").focus();
return false;
}
return true;
}
 
Share this answer
 
yes u can do.
here is an example for the same using custom validator

this is the javascript, i have used the script to check if my text entered is of length 5, u can write ur alert method inside the else loop.

XML
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    function checkNAME(Source,args)
    {
    var a = document.getElementById("TextBox1").value;
    if(a.length == 5){
    args.IsValid = true;
    }
    else{
    args.IsValid = false;
    }
    }
    </script>
</head>


This is the asp control and its property

XML
<asp:CustomValidator ID="CustomValidator1" runat="server"
            ErrorMessage="CustomValidator" ClientValidationFunction="checkNAME"
            ControlToValidate="TextBox1"></asp:CustomValidator>


ClientValidationFunction wil call the javascript wher u can check for the function u want and display the message.
 
Share this answer
 
v2
Comments
Thiagarajan Duraisamy 21-Sep-11 3:54am    
hope this is wat u were looking for

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900