Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem with 'return false;'

    I have the following form:
    <form action="/cgi-bin/script.cgi" method="POST" onsubmit="check_create()">
    <fieldset>
    <legend>Create project</legend>
    Type <input id="type" type="text" name="type" size="20" /><br/>
    Name <input id="project" type="text" name="project" size="20" /><br/>
    Language to use <input id="language" type="text" name="language" size="20"/><br/>
    <input type="hidden" name="profile" value="[% profile %]"/>
    <input type="submit" value="Create" />
    </fieldset>
    </form><br/>
    and check_create function is:
    function check_create() {

    var type = document.getElementById('type').value;
    var pname = document.getElementById('project').value;
    var language = document.getElementById('language').value;
    if ((type == '') || (pname == '') || (language == '')) {
    alert('You must complete form');
    return false;
    }
    else alert('Ok');

    }
    The problem is that return false doesn't work, but form lanch /cgi-bin/script.cgi.
    Where is the problem? Why return false doesn' work?

    Regards,
    savio

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    onsubmit="return check_create()"


  •  

    Posting Permissions

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