Results 1 to 2 of 2

Thread: Need Help In JavaScript

  1. #1
    Join Date
    Feb 2009
    New York, USA

    Need Help In JavaScript

    Hey guys,

    My Board - Donation Page

    I have a form here and I have JavaScript set to require a minimum value. Currently, the Javascript is:

    HTML Code:
    <script type="text/javascript">
    function validate_form ( )
    valid = true;
    if ( document.donation_form.amount.value < "5" )
    alert ( "Please enter a minimum of 5 USD." );
    valid = false;
    return valid;
    However, when you add anything 10+ it gives an error. Can anybody figure out why its doing this? The problem seems to be that its only reading the first digit, so if you have anything from 10 to 49 it will give an error, but when you get to 50 its fine again.
    WiredStorm Hosting Solutions
    █ Lightning Fast Shared and Reseller Hosting
    █ cPanel with Softaculous and 24/7 Email (Ticket) Support
    Biodegradable Sunscreen - Unblock Facebook

  2. #2
    JavaScript can sometimes be hard to troubleshoot because it operates slightly differently in IE and FireFox.

    Try removing the quotes from around the "5". Normally, it should not matter, but you are treating it as a string rather than a numeric value. It's a good idea to leave the quotes off of numeric values.

    Make sure that you test all JavaScript in several different browsers.
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin

Similar Threads

  1. [Free] Static Javascript PHP
    By codename_B in forum Scripts
    Replies: 0
    Last Post: 13 January, 2011, 17:51 PM
  2. Javascript
    By Sbfc_ in forum Community Building
    Replies: 5
    Last Post: 19 March, 2010, 00:21 AM
  3. Javascript
    By KMRock in forum Programming
    Replies: 0
    Last Post: 29 July, 2009, 01:02 AM
  4. JavaScript for links
    By Micks86 in forum Promoting
    Replies: 2
    Last Post: 20 June, 2009, 00:58 AM
  5. [WTH] $$ for Simple Javascript
    By MarxGrayscaleServices in forum Services
    Replies: 2
    Last Post: 31 May, 2009, 19:31 PM

Tags for this Thread


Posting Permissions

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