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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:29:20+00:00 2026-06-09T21:29:20+00:00

Trying to write a script that will check the value in the form is

  • 0

Trying to write a script that will check the value in the form is a number between the range of 1 to 99999.

1) The script work mostly except for two things if you put a number then letter it won’t detect that you entered letters as well as numbers

2) I want it to run the script on onblur event, however every time I try the script does not work at all.

Did study java years and year ago and found I forgotten most things if people can point out where I am going wrong would be very greatful

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Please enter your age</title>
<script language="JavaScript1.2">
function checknumber(){
var x=document.checknum.pnum.value
/*does it contain non digits */
var anum=/(^\D+$)|(^\D+\.\D+$)/
if (anum.test(x))
{
alert("Please input a valid Runner ID between 1 to 99999 !")
testresult=false
}
/*is it above 99999*/
else if (x > 99999)
{
alert("Please input a valid Runner ID between 1 to 99999 !")
testresult=false
}
/*is it below 1*/
else if (x < 1)
{
alert("Please input a valid Runner ID between 1 to 99999 !")
testresult=false
}
return (testresult)
}
</script>
</head>
<body>
<form name="checknum" onSubmit="return checknumber()">
Please input a valid Runner ID between 1 to 99999:
<input type="text" name="pnum" onchange="checknumber()">
<input type="submit" value="Submit">
</form>
</body>
</html>

Many Thanks
Damien

  • 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-09T21:29:22+00:00Added an answer on June 9, 2026 at 9:29 pm

    Import Jquery Library and use this function

    <script type="text/javascript">
    
    $(document).ready(function(){    
    $("#pnum").keypress(function (e)  
    { 
      //if the letter is not digit then display error and don't type anything
      if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
      {
        return false;
      } 
    });
    });
    

    but id for the textbox

     <input type="text" name="pnum" id="pnum" maxLength="5" > 
    

    this will ensure that you can add numbers only and 5 char

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

Sidebar

Related Questions

Noob help please. I'm trying to write a script that will check if a
I'm trying to write a script that will create a user in MediaWiki, so
I'm trying to write a script that will download files from an FTP server.
I'm currently trying to write a script that will connect to a site using
THANKS FOR HELPING!!! Ok... So I am trying to write a script that will
I'm trying to write a Photoshop script that will show all layers of a
I'm trying to write an R script that will go through a dataframe that
I'm trying to write a bash script that will process a list of files
I'm trying to write a Perl script that will parse the output of the
I am trying to write a custom script that will keep a list of

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.