Validation Plugin Not Working
I've been trying to get this working for hours and can't work out why it's not working - can anybody help? Nothing happens at all, no validation or anything!
index.php:
- <?php
- include '../db/connect.php';
- include 'course_finder.php';
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Matcher | Register</title>
- <meta name="viewport" content="width=400" />
- <link rel="stylesheet" href="../css/style.css" />
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
- <script type="text/javascript" src="../js/validate.js"></script>
- <script type="text/javascript" src="../js/js.js"></script>
- </head>
- <body>
- <section id="page">
- <header id="page_head">
- <a href="../">
- <div id="app_title">
- <img id="logo" src="../img/aru.gif"/>
- <h1>Module Matcher</h1>
- </div>
- </a>
- <h2>Register</h2>
- </header>
- <form id="register" method="post" action="adduser.php">
- <p class="star">* indicates required field</p>
- <h3>Account Information</h3>
-
- <label for="username">Username *</label>
- <p class="clarification">no spaces please</p>
- <input id="username" name="username">
-
- <label for="password">Password *</label>
- <input id="password" type="password" name="password">
-
- <label for="password_confirm">Confirm Password *</label>
- <input id="password_confirm" type="password" name="password_confirm">
- <label for="real_name">Real Name *</label>
- <input id="real_name" name="real_name">
-
- <label for="email">Email Address *</label>
- <p class="clarification">not displayed publicly by default</p>
- <input id="email" type="email" name="email">
-
- <h3>Course Information</h3>
-
- <label for="year">University Start Year *</label>
- <input id="year" type="number" value="2012" name="year">
- <script type="text/javascript">
- $(document).ready(function() {
- $('#loading').hide();
- $('#department').change(function(){
- $('#loading').show();
- $('#result_1').hide();
- $.get("course_finder.php", {
- func: "course_get",
- department_var: $('#department').val()
- }, function(response){
- $('#result_1').fadeOut();
- setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
- });
- return false;
- });
- });
- function finishAjax(id, response) {
- $('#loading').hide();
- $('#'+id).html(unescape(response));
- $('#'+id).fadeIn();
- }
- </script>
-
- <label for="department">Department</label>
- <select name="department" id="department">
- <option value="" selected="selected" disabled="disabled">Select a Department</option>
- <option value="Arts, Law and Social Sciences">Arts, Law and Social Sciences</option>
- <option value="Health, Social Care and Education">Health, Social Care and Education</option>
- <option value="Lord Ashcroft International Business School">Lord Ashcroft International Business School</option>
- <option value="Science and Technology">Science and Technology</option>
- </select>
-
- <span id="loading" style="display: none;">
- <p>Loading courses...</p>
- </span>
- <span id="result_1" style="display: none;"></span>
-
- <h3>Contact Information</h3>
-
-
- <label for="facebook">Facebook Username</label>
- <input id="facebook" name="facebook">
-
- <label for="twitter">Twitter Username</label>
- <input id="twitter" name="twitter">
-
- <input id="submit" type="submit">
-
- </form>
- </section>
- </body>
- </html>
js.js:
- $.validator.setDefaults({
- submitHandler: function() { alert("submitted!"); }
- });
- $().ready(function() {
- $("#register").validate({
- rules: {
- username: {
- required: true,
- minlength: 2
- },
- password: {
- required: true,
- minlength: 5
- },
- password_confirm: {
- required: true,
- minlength: 5,
- equalTo: "#password"
- },
- real_name: {
- required: true
- },
- email: {
- required: true,
- email: true
- },
- year: {
- required: true,
- digits: true
- }
- },
- messages: {
- username: {
- required: "Please enter a username",
- minlength: "Your username must consist of at least 2 characters"
- },
- password: {
- required: "Please enter a password",
- minlength: "You password must consist of at least 5 characters"
- },
- password_confirm: {
- required: "Please confirm your password",
- equalTo: "Passwords do not match"
- },
- real_name: {
- required: "Please enter your real name"
- },
- email {
- required: "Please enter a valid email address"
- },
- year {
- required: "Please enter a valid year"
- }
- }
- });
- });
Thanks so much!!