hi
my page contains a button with a javascript click event.
when i click the button i want to check if the page is valid, and if the answer is yes, to perform the event function. if the page is not valid i want the error message to show in the page's validation summary.

i tired a few code lines:

function btnLogin_Click()
     {
       if (AllValidatorsValid(Page_Validators))
       { 
        var a = document.getElementById('ctl00_ContentPlaceHolder1_txt1').value;
        var b = document.getElementById('ctl00_ContentPlaceHolder1_txt2').value;
       
        alert(a + " " + b);
       }
     }

i also tried:

if (Page_isValid)
{
 ....
}

nothing seems to work.

found the answer.

if (Page_ClientValidate("g1"))
{
.....
}

g1 is the validation group.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.