Hello.

This is probably something very simple that I am missing (Or something that I have done wrong), but upon filling in and validating all fields of the form and pressing the "Register" button nothing happens; Usually the page would reload as if the form had been submitted.

The code is below. Thank you in advance.

`

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<title>jQuery Form Validation</title>

</head>
<body>
<form id="DemoForm"
<form method = 'post' action = 'jTest1.8.html' id = 'DemoForm' name = 'DemoForm'>
    Username<br />
    <input type="text" id="user_input" name="username" /><br>
    Email<br />
    <input type="text" id="email" name="email" /><br>       
</form>
<div id="test">
</div>

<!--Rules & Messages-->

<!--Username-->

<!--Email-->
      <script src = 'jquery.validate.min.js'></script>    
      <script>
         $('#DemoForm').validate ({
            rules: {
                        'email': {
                                    required:'true',
                                    email: 'true',
                                    }
                      },
                      messages:{
                           'email':{
                           required:'Please submit your email.',
                           email:'Enter a valid email.',
                                       }
                                       },


                                                   });
      </script>


</body>

</html>

<!--Password Validation-->
<script src = 'jquery.validate.min.js'></script>
<form id="DemoForm">
<form method = 'post' action = 'jTest1.8.html' id = 'DemoForm' name = 'DemoForm'>
<label for="password">Password</label><br>
<input id="password" name="password" />
<br/>
<label for="password_again">Again</label><br>
<input class="left" id="password_again" name="password_again" />
<br>

<input type="submit" id="register" value="Register" />
</form>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
  debug: true,
  success: "valid"
});
$( "#myform" ).validate({
  rules: {
    password: "required",
    password_again: {
      equalTo: "#password"
    }
  }
});
</script>

`

Recommended Answers

All 5 Replies

I think you need to remove line 51.

UPDATE: It now appears to be submitting, but the validation for the password fields do not throw errors when incorrect. Very confused.

Problems resolved for now (I think).

Hi,

Please could you post the resolution as I would be interested to see what it was?

Kind Regards,

Piers

it was the malformed HTML and the douped form id...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.