Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:16:11+00:00 2026-06-14T17:16:11+00:00

I am trying to enforce 15-minute granularity for time information entered by the user.

  • 0

I am trying to enforce 15-minute granularity for time information entered by the user. So, for example, 12:15 PM and 3:45 am and 9:30 A.M. are all acceptable, but 2:35 PM would not be allowed. Server-side validation works, but it would be nice if the user was told their input was invalid when the text box loses focus, before they click the submit button. Here is the code:

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True" UpdateMode="Always">
            <ContentTemplate>
                <asp:TextBox ID="txtStartTime" runat="server" AutoPostBack="True" CausesValidation="True"/>
                <Ajax:MaskedEditExtender ID="txtStartTime_MaskedEditExtender" runat="server" 
                    TargetControlID="txtStartTime" MaskType="Time" AcceptAMPM="True"
                    Mask="99:99">
                </Ajax:MaskedEditExtender>
                <asp:RequiredFieldValidator runat="server" ID="StartTimeRequired" 
                    ValidationGroup="EventAddEditControls" ControlToValidate="txtStartTime" 
                    EnableClientScript="True" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ErrorMessage="Invalid time format." ControlToValidate="txtStartTime" 
                    ValidationGroup="EventAddEditControls" SetFocusOnError="True" 
                    EnableClientScript="True" Text="Invalid time format."
                    ValidationExpression="^([1-9]|0[1-9]|1[012]):(00|15|30|45)\s?[aApP]\.?[mM]\.?$" />
                <Ajax:MaskedEditValidator ID="MaskedEditValidator1" ControlToValidate="txtStartTime"
                    ControlExtender="txtStartTime_MaskedEditExtender" IsValidEmpty="False" 
                    ValidationGroup="EventAddEditControls" 
                    ValidationExpression="^([1-9]|0[1-9]|1[012]):(00|15|30|45)\s?[aApP]\.?[mM]\.?$" 
                    EnableClientScript="True" SetFocusOnError="True" Text="Time format is invalid."
                    runat="server"></Ajax:MaskedEditValidator>
            </ContentTemplate>
        </asp:UpdatePanel>

How can I get the MaskedEditExtender to enforce the 15-minute granularity constraint on the client side also (assuming that this is possible)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:16:13+00:00Added an answer on June 14, 2026 at 5:16 pm

    This seems overly simple, but it seems to work.

    The first thing I did was to comment out the RegularExpressionValidator – you don’t really need both this and the MaskedEditValidator. To prove the point, apply the fix below but don’t comment out the RegularExpressionValidator. Upon a failed validation you will see both errors.

    The last thing was to replace the Text property of the MaskedEditValidator with the InvalidValueMessage property:

    <Ajax:MaskedEditValidator ID="MaskedEditValidator1" ControlToValidate="txtStartTime"
        ControlExtender="txtStartTime_MaskedEditExtender" IsValidEmpty="False" 
        ValidationGroup="EventAddEditControls" 
        ValidationExpression="^([1-9]|0[1-9]|1[012]):(00|15|30|45)\s?[aApP]\.?[mM]\.?$" 
        EnableClientScript="True" SetFocusOnError="True"
        InvalidValueMessage="Time format is invalid." runat="server">
    </Ajax:MaskedEditValidator>
    

    This example gave me the hint regarding the correct property to use.

    Doing both of these things resulted in the validation occurring when tabbing out of the control. This also indicates that the MaskedEditValidator was validating all along.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to enforce a time limit on queries in python MySQLDB. I have
In a recent code review, a contributor is trying to enforce that all NULL
I'm trying to enforce a specific order for tasks to complete using Grand Central
I am trying to enforce the first name of my model to be any
I'm trying to enforce windows authentication for users of a .Net application on Web
In Java, I am trying to get DecimalFormat to enforce the sign on an
I'm trying to enforce integrity on a table in a way which I do
I'm trying to enforce TLS for out going mail to a single host. I'm
I am trying to enforce a policy where each push gets rejected when even
I'm learning about remoting by doing small remoting-based projects and also trying to enforce

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.