469,934 Members | 2,556 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

image/imagebutton client validation

Hi

is there any way i can call a clientside function for validation onClick of
a Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even it
return false from the clientside function.

my sample code has,
..aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value
!= ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"
runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme() ) ")

Any ideas??

Thanks

Ganesh kolappan.


Nov 17 '05 #1
2 4841
Have you looked at client-side customvalidators?
http://msdn.microsoft.com/library/de...datorclass.asp

Karl

"ganesh kolappan" <ho********@yahoo.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi

is there any way i can call a clientside function for validation onClick of a Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even it
return false from the clientside function.

my sample code has,
.aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value != ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"
runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme() ) ")

Any ideas??

Thanks

Ganesh kolappan.

Nov 17 '05 #2
....attribute.add("OnClick","return validateMe();")
-----Original Message-----
Hi

is there any way i can call a clientside function for validation onClick ofa Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even itreturn false from the clientside function.

my sample code has,
..aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value!= ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme () ) ")
Any ideas??

Thanks

Ganesh kolappan.


.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by ruca | last post: by
3 posts views Thread by Varangian | last post: by
5 posts views Thread by Varangian | last post: by
2 posts views Thread by CK | last post: by
10 posts views Thread by Edwin Knoppert | last post: by
9 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.