SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot matches's Avatar
    Join Date
    Aug 2006
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    disable form submit button

    Hey folks,

    Need a little help. I have a page with three forms. I need to disable form 2 and 3 until all the required fields in form 1 have a value. Once all required fields in form 1 have a value, i need the disabled submit buttons to enable without a page refresh. Any help is appreciated. Thanks!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by matches View Post
    Once all required fields in form 1 have a value, i need the disabled submit buttons to enable without a page refresh.
    That should be as easy as setting an onsubmit event for those other forms, which checks to see if what they need is there. If not, they return false to prevent the form from being submitted.

    For example:

    Code javascript:
    var shipping = document.getElementById('shipping');
    form3.onsubmit = function () {
        if (!validateShoppingCart() || !validatePersonalDetails()) {
            return false;
        }
    };

    That's a good starting point for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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