image/imagebutton client validation

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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.




    ganesh kolappan Guest

  2. Similar Questions and Discussions

    1. An ImageButton that retrieves its image from a Resource
      I can't find any documentation on retrieving an imagebutton's image from a resource file in asp.net 2.0. Can someone help with a small example or...
    2. Help with asp:imagebutton image path
      Hi I'm a little stuck and hoping for some advice, asp.net vb I have a datalist on a page to show users thumbnails, the photos are displayed as...
    3. Need to change image of imagebutton in datagrid template column
      I'm going nuts.. I've got a template column with an imagebutton in it. I would like to change the image on the button when the button is clicked. ...
    4. Client Validation without Js
      Hi....I have a problem with my asp page, when it have diferent controls and some validation control...but i want to validate just some controls if...
    5. validation summary doesnt display when there's client-side validation
      I have a custom validator that validates a numeric field, txtField, that allows for thousand separators. I also placed a validation summary so...
  3. #2

    Default Re: image/imagebutton client validation

    Have you looked at client-side customvalidators?
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mwsdk/html/mwlrfcustomvalidatorclass.asp[/url]

    Karl

    "ganesh kolappan" <hookit2000@yahoo.com> wrote in message
    news:OeW4foXQDHA.2832@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.
    >
    >
    >
    >

    Karl Seguin Guest

  4. #3

    Default image/imagebutton client validation

    ....attribute.add("OnClick","return validateMe();")
    >-----Original Message-----
    >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.
    >
    >
    >
    >
    >.
    >
    David Waz... Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139