Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法使jQuery验证工作_Php_Jquery_Codeigniter_Validation_Wampserver - Fatal编程技术网

Php 无法使jQuery验证工作

Php 无法使jQuery验证工作,php,jquery,codeigniter,validation,wampserver,Php,Jquery,Codeigniter,Validation,Wampserver,我正在使用php和CodeIgniter。我是这两方面的新手(职业VB.Net和C#developer)。然而,为了创建一个基本的注册表单,我很难让jQuery验证工作起来 header.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); ?><!DOCTYPE html> <html> <head> <?php if(is

我正在使用php和CodeIgniter。我是这两方面的新手(职业VB.Net和C#developer)。然而,为了创建一个基本的注册表单,我很难让jQuery验证工作起来

header.php

<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?><!DOCTYPE html>
<html>
    <head>
        <?php if(isset($title)) {?>
            <title>Discuss Cards - <?php echo $title ?></title>
        <?php } else { ?>
            <title>Discuss Cards</title>
        <?php } ?>
        <link rel="stylesheet" href="<?php echo base_url();?>styles/forum.css" type="text/css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">    </script>
        <script src="<?php echo base_url();?>js/jquery.validate.min.js"></script>
    </head>
    <body>
        <?php if(isset($title)) {?>
            <h1><?php echo $title?></h1>
        <?php } ?>
        <?php if (isset($page_description)) {?>
            <p id="page_description"><?php echo $page_description?></p>
        <?php } ?>

讨论卡片-
讨论卡片

评论有点太长了,但不确定这是否是唯一的问题。我看到的第一件事是

<script>
    $("#createaccount").validate();
</script>

(理想情况下,您将所有JS放在页面末尾,在结束标记之前)

,这样做了。非常感谢您的帮助。@XstreamINsanity太棒了,它帮了我的忙!不客气。
        <strong>&copy; 2016</strong>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <title>Discuss Cards - Create New Account</title>
        <link rel="stylesheet" href="http://[::1]/forum/styles/forum.css" type="text/css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
        <script src="http://[::1]/forum/js/jquery.validate.min.js"></script>
    </head>
    <body>
        <h1>Create New Account</h1>
        <script>
            $("#createaccount").validate();
        </script>
        <form action="http://[::1]/forum/index.php/user/create_account" id="createaccount" method="post" accept-charset="utf-8">
            <label for="txtEmail">Email</label>
            <br>
            <input type="email" name="txtEmail" value id="txtEmail" maxlength="50" minlength="2">
            <br>
            <br>
            <label for="txtUsername"></label>
            <br>
            <input type="text" name="txtUsername" value id="txtUsername" maxlength="50" minlength="5">
            <br>
            <br>
            <label for="pswPassword">Password</label>
            <br>
            <input type="password" name="pswPassword" value id="pswPassword">
            <br>
            <br>
            <label for="pswConfirmPassword">Confirm Password</label>
            <br>
            <input type="password" name="pswConfirmPassword" value id="pswConfirmPassword">
            <br>
            <br>
            <input type="submit" value="Register" name="Register">
        </form>
        <strong>© 2016</strong>
    </body>
</html>
<form class="cmxform" id="commentForm" method="get" action="">
  <fieldset>
    <legend>Please provide your name, email address (won't be published) and a comment</legend>
    <p>
      <label for="cname">Name (required, at least 2 characters)</label>
      <input id="cname" name="name" minlength="2" type="text" required>
    </p>
    <p>
      <label for="cemail">E-Mail (required)</label>
      <input id="cemail" type="email" name="email" required>
    </p>
    <p>
      <label for="curl">URL (optional)</label>
      <input id="curl" type="url" name="url">
    </p>
    <p>
      <label for="ccomment">Your comment (required)</label>
      <textarea id="ccomment" name="comment" required></textarea>
    </p>
    <p>
      <input class="submit" type="submit" value="Submit">
    </p>
  </fieldset>
</form>
<script>
$("#commentForm").validate();
</script>
<script>
    $("#createaccount").validate();
</script>
$( document ).ready( function( ) {
    $("#createaccount").validate();
}