5 Replies - 574 Views - Last Post: 19 May 2017 - 08:05 AM Rate Topic: -----

#1 eggybread  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 04-May 17

Validation not working on Image Button

Posted 19 May 2017 - 07:29 AM

Hi, I'm trying to set validation on an image button. But the following still lets me click the button and throws an error if I input an invalid character. I need it to allow only decimal values (money amounts) with no pound or dollar signs eg: 0.00 or 1.50 or 235.57 etc. I'm using Asp.Net & VB....

        <asp:TextBox ID="txtBackAmount" placeholder="Enter Amount" runat="server" Columns="12"></asp:TextBox>

        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Invalid Amount"
            ControlToValidate="txtBackAmount" Display="Dynamic" ValidationGroup="save">*</asp:RequiredFieldValidator>

        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Invalid Amount"
            ControlToValidate="txtBackAmount" ValidationExpression="^\d+(\.\d{0,2})"
            Display="Dynamic" ValidationGroup="save">*</asp:RegularExpressionValidator>

        <asp:ImageButton ID="imgYes" width="100px" ImageUrl="~/files/images/gift.png" runat="server"
            ValidationGroup="save" CausesValidation="true"  />



Any help is appreciated x

Is This A Good Question/Topic? 0
  • +

Replies To: Validation not working on Image Button

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: Validation not working on Image Button

Posted 19 May 2017 - 07:45 AM

Works for me.. also works when I get rid of the extra kruft like the *that was preventing the messages from showing up, the 'causes validation' which should be happening automatically on post back, and the validation group..


<asp:TextBox ID="txtBackAmount" placeholder="Enter Amount" runat="server" Columns="12"></asp:TextBox>

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Invalid Amount1"
                ControlToValidate="txtBackAmount" Display="Dynamic"></asp:RequiredFieldValidator>

            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Invalid Amount2"
                ControlToValidate="txtBackAmount" ValidationExpression="^\d+(\.\d{0,2})"
                Display="Dynamic"></asp:RegularExpressionValidator>

            <asp:ImageButton ID="imgYes" Width="100px" ImageUrl="" runat="server" BorderStyle="Dotted" />

Was This Post Helpful? 0
  • +
  • -

#3 eggybread  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 04-May 17

Re: Validation not working on Image Button

Posted 19 May 2017 - 07:57 AM

View Postmodi123_1, on 19 May 2017 - 07:45 AM, said:

Works for me.. also works when I get rid of the extra kruft like the *that was preventing the messages from showing up, the 'causes validation' which should be happening automatically on post back, and the validation group..


<asp:TextBox ID="txtBackAmount" placeholder="Enter Amount" runat="server" Columns="12"></asp:TextBox>

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Invalid Amount1"
                ControlToValidate="txtBackAmount" Display="Dynamic"></asp:RequiredFieldValidator>

            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Invalid Amount2"
                ControlToValidate="txtBackAmount" ValidationExpression="^\d+(\.\d{0,2})"
                Display="Dynamic"></asp:RegularExpressionValidator>

            <asp:ImageButton ID="imgYes" Width="100px" ImageUrl="" runat="server" BorderStyle="Dotted" />


That's weird. I use this on the VB side..

    Protected Sub imgYes_Click(sender As Object, e As System.EventArgs) Handles imgYes.Click


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: Validation not working on Image Button

Posted 19 May 2017 - 07:58 AM

What relevance does that have?

Side note - you don't need to quote the post above yours.. you can just use the reply button.
Was This Post Helpful? 0
  • +
  • -

#5 eggybread  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 04-May 17

Re: Validation not working on Image Button

Posted 19 May 2017 - 08:04 AM

I'm also doing this within a nyroModal window, not sure if that makes a difference?
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: Validation not working on Image Button

Posted 19 May 2017 - 08:05 AM

*shrug* Never heard of it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1