我正在尝试使用 jquery form validator 实现客户端验证但我已经按照指南进行操作,并且在谷歌搜索我的问题的答案时也注意到可能与 prototype.js
发生冲突我添加了 var JQuery = jQuery.noConflict();
到我的 jquery-1.5.1.min.js
文件的底部。
Firebug 还在说
$("#contact") 为空
$("#contact").validationEngine();
我已将所需的 javascript 和 jQuery 代码加载到我的主页 template.php 文件
中,然后调用一个名为 contact 的 view
。
联系页面浏览量:
<section id="content" class="contact-us">
<h1>Contact</h1>
<div id ="formLayout" class="contactForm">
<section id = "validation"></section>
<form action=contact" method="post" accept-charset="utf-8" id="contact" name="contact">
<fieldset>
<label><label for="name">Name:</label><span class="small">Required Field - Text</span></label>
<input type="text" name="name" value="" id="name" class="validate[required[custom[onlyLetterSp]]]" />
<div id="error"></div>
<label><label for="email">Email:</label><span class="small">Required Field - yourname@example.com</span></label>
<input type="text" name="email" value="" id="email" class="validate[required[custom[onlyLetterSp]]]" />
<div id="error"></div>
<label><label for="phone">Phone:</label><span class="small">Required Field - 021214589</span></label>
<input type="text" name="phone" value="" id="phone" class="validate[required[custom[onlyLetterSp]]]" />
<div id="error"></div>
<label><label for="message">Message:</label><span class="small">Required Field - Text</span></label>
<textarea name="message" cols="90" rows="12" id="message" class="validate[required[custom[onlyLetterSp]]]" >
</textarea><div id="error"></div>
<input type="submit" name="submit" value="Submit" />
</fieldset>
</form>
</div>
</section>
</div>
<div class="clear"></div>
<footer>© Housemovers LTD 2011</footer>
</div> <!-- Wrapper Close -->
<script type="text/javascript" src="http://jesse.mckenzie.natcoll.net.nz/_Assignments/Industry/includes/js/jquery-1.5.1.min.js"></script>
<script src="/includes/js/lightbox/prototype.js" type="text/javascript"></script>
<script src="/includes/js/lightbox/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
<script src="/includes/js/lightbox/lightbox.js" type="text/javascript"></script>
<script src="includes/js/jquery.validationEngine-en.js"type="text/javascript"></script>
<script src="/includes/js/jquery.validationEngine.js"type="text/javascript"></script>
<script type="text/javascript">
JQuery(document).ready(function(){
$("#contact").validationEngine();
});
</script>
</body>
最佳答案
改成
jQuery("#contact")
.noConflict()
移除了绑定(bind)到 jQuery 的 $
关于javascript - $ ("value") 为空 -> jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5906129/