www.webdeveloper.com
Results 1 to 5 of 5

Thread: Comparing An Entered Number To A Standard

  1. #1
    Join Date
    Jun 2004
    Location
    Rhode Island
    Posts
    3

    Comparing An Entered Number To A Standard

    Hi Everyone!

    Firstly, I am a newbie here, so please bear with me as I clumsily get around.

    Secondly, I am the Website Manager for my company, Exeter Fuel (www.exeterfuel.com). I am not a programmer by any means, but a writer who's been requested to handle managing the site, so I am learning and if I am in the wrong place for this, please let me know!

    Now, if you are still with me, I need to know how to do a certain task for one of my webpages. It is an order online page which asks a number of questions. One of the specifications for ordering calls for a quantity of fuel (in gallons) requested. I currently have a text box for that, but my boss wants to make sure they can't enter any number less than a minimum. For example, to order home heating oil the required minimum is 100 gals. Is there any javascript available that could take whatever the user entered and compare that to the minimum and kick back a message saying they must enter something equal to or greater than 100 if it's less than 100? I hope that question makes sense! I have checked the JavaScriptSource website, but can't seem to find anything that might work.

    The page in question is https://exeterfuel.ixwebhosting.com/orderonline.html

    Any help would be greatly appreciated! If you need more info, just holler! If I am out-of-line doing this, just holler about that too!
    BobE

  2. #2
    Join Date
    May 2004
    Location
    St. Louis, Missouri, USA
    Posts
    164
    Here is one of your text boxes from your page...
    Code:
    <TR>
              <TD width="50%"><INPUT type=radio value=diesel name=product2> <FONT 
                face=arial,helvetica size=-2><B>Diesel (Min. 500 gal.)</B></FONT></TD>
              <TD width="50%"><INPUT type=radio value=diefill name=qty> <FONT 
                face=arial,helvetica size=-2><B>Fill Tank</B> or <B>Quantity</B> 
                <INPUT size=6 name=qty onBlur="checkMin(500, this.value, this)"></FONT></TD></TR>
    Notice the Red, that is what I changed. Put that in each text box declaration (change 500 to the minimum number of gallons). Then, here is the function that goes in the head
    Code:
    function checkMin(min, input, obj){
    	if (obj.value != ""){
    		if (input < min){
    			alert('You must fill at least ' + min + ' gallons');
    			obj.select();
    		}	
    	}
    }
    If the text box is not blank, it reads the value and if it's less than the min, it tells the user they must input at least the min, then it selects the text. Hope this helps you out.

  3. #3
    Join Date
    Jun 2004
    Location
    Rhode Island
    Posts
    3
    theBody44...

    Thank you so much! I can't try it right now because my files are at work, but as soon as I get back there I'll give it a shot!

    Thanks so much for the fast reply and code!
    BobE

  4. #4
    Join Date
    Jun 2004
    Location
    Rhode Island
    Posts
    3
    Body44....

    Your suggested script worked Great! For the other fields I did as you said, just changed the standard and they all worked fine!

    Many thanks for your help!
    BobE

  5. #5
    Join Date
    May 2004
    Location
    St. Louis, Missouri, USA
    Posts
    164

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles