views:

45

answers:

1

I got stuck today, been searching on stack overflow and google, however havnt had much luck in implementing the solutions I've seen. I have a form, Im trying to create, when i click submit when theres no info in the forms, it prompts an error (it didnt validate), however when everything is filled out correctly, the submit button no longer works.

<script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="js/jquery.delegate.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
 debug: true,
 success: "valid"
});;
</script>

  <script type="text/javascript">
  $(document).ready(function(){
    $("#q0").validate({
  rules: {
   date1: {
    required: true,
    digits: true,
    rangelength: [4, 4],
    min: 2010,
    max: 2015
  },
   date2: {
    required: true,
    digits: true,
    rangelength: [2, 2],
    max: 12
  },
   date3: {
    required: true,
    digits: true,
    rangelength: [2, 2],
    max: 31
  },
   date4: {
    required: true,
    digits: true,
    rangelength: [2, 2],
    max: 23
  },
   date5: {
    required: true,
    digits: true,
    rangelength: [2, 2],
    max: 59
  }
 }
});
  });
  </script>

Next we have the form:

<h1>Select User</h1>
   <form action="q1.php" method="post" id="q0"><br /><br />

<?php

$con = mysql_connect("localhost","","");
if (!$con)
  {
  die('PWND: ' . mysql_error());
  }

                mysql_select_db("questionnaire");


    $sql = "SELECT id, fname, lname 
      FROM   User";

                $result = mysql_query($sql);
     echo '<select name="User" type="number">';
                while ($row = mysql_fetch_assoc($result))
                {
                    echo '<option value="'.$row['id'].'">'.$row['fname'].' '.$row['lname'].'</option>';
                }
     echo '</select>';
mysql_close($con)
?><br /><br />
<p>
<h4>Date and Time</h4>

  <label for="date1">Year (YYYY): </label>
  <input class="left" id="date1" name="date1" />
  <br/>
  <label for="date2">Month (MM): </label>
  <input class="left" id="date2" name="date2" />
  <br/>
  <label for="date3">Day (DD): </label>
  <input class="left" id="date3" name="date3" />
  <br/>
  <label for="date4">Hour (HH): </label>
  <input class="left" id="date4" name="date4" />
  <br/>
  <label for="date5">Minute (MM): </label>
  <input class="left" id="date5" name="date5" />
  <br/>
</p>
<h4>Test</h4>
<select name="qtype" type="number">
<option value="1">0</option>
<option value="2">8</option>
<option value="3">1</option>
<option value="4">2</option>
<option value="5">3</option>
<option value="6">4</option>
<option value="7">5</option>
</select><br /></p>
<input type="submit" value="Submit"/>
</form>

Basically I would like it to post to the next page, like it did previously, however since I tried jquery the submit button has stopped working, seems like after it validates.

I've been looking at: http://docs.jquery.com/Plugins/Validation (this was my main resource to getting this going). http://stackoverflow.com/questions/882406/jquery-disable-button-not-submit-until-field-validates-validation-plugin http://stackoverflow.com/questions/1075651/help-understanding-jquery-button-enable-disable-code

However I still seem to be stuck, not sure I messed up the code above somewhere. The submit button remains broken.

+3  A: 

It's the debug option you have set:

debug: true,

Just remove the option or set it to false, it prevents submission for testing, to get a submit to go through you'll need to change it, from the docs:

Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages.

Nick Craver
Thank you! This resolved my issue!
imbadatjquery