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 7496669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:43:39+00:00 2026-05-29T18:43:39+00:00

In my application you fill in a number in an input field that gets

  • 0

In my application you fill in a number in an input field that gets validated on the client side by different validators. I have an external JS-file with code that puts the input field in focus and selects the previous entered number. I’ve also have included “defaultbutton” in my form tag so that typing a new number and submitting the form is easy and goes fast (just type again and press ENTER)

Everything works fine except one thing. When typing a number that’s out of the allowed range or leaving the input field empty the error message is shown only if clicking the submit button with the mouse button. If clicking with ENTER, the “*” next to the input field is shown, but not the error message.

I hope the code below is enough to be able to see what’s wrong.

Thanks in advance.

<form id="form1" runat="server" defaultbutton="btnCheckNr">
...
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
    <asp:TextBox ID="inputBox" runat="server" Height="22px" Width="75px" />

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="inputBox" Display="Dynamic" 
            ErrorMessage="Type a number between 1 and 100." SetFocusOnError="True">*</asp:RequiredFieldValidator>

        <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Skriv ett heltal mellan 1 och 100." Text="*"
            MaximumValue="100" MinimumValue="1" Type="Integer" ControlToValidate="inputBox" Display="Dynamic"></asp:RangeValidator>

    <asp:Button ID="btnCheckNr" runat="server" Text="Skicka gissning" onclick="btnCheckNr_Click" />

...
</form>

JS:

var Capsule = {

    init: function() {
        var input = $('#inputBox');

        if (!input.is(":disabled")) {
            input.focus();
            input.select();
        }
    }
}

window.onload = Capsule.init;
  • 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-05-29T18:43:47+00:00Added an answer on May 29, 2026 at 6:43 pm

    Correct me if I am wrong but it looks like your range validator needs to be modified as well as your required field validator.

    Shouldnt it be like this?

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="inputBox" Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
    
    <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Skriv ett heltal mellan 1 och 100." MaximumValue="100" MinimumValue="1" Type="Integer" ControlToValidate="inputBox" Display="Dynamic"></asp:RangeValidator>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that creates a number of Visual Foxpro (DBF) tables. Each
I have an application I am making that creates a large number of windows
I have started writing an application that gets in a certain website and gets
I have a lotus notes application that has a document with a Number ,
I have a GridView in my Android application that has a number of ImageViews
I have a C# application that submits information to an Access database. I fill
I am trying to make an application that will fill in the info i
in my application I have a few CListCtrl tables. I fill/refresh them with data
I have an application writted in ASP with a simple form. The users fill
I'm working on an application for iOS which will have the user fill out

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.