1

http://jsfiddle.net/ssthil/zj7F8/

它没有开火,我错过了哪里?你能帮忙吗?

4

2 回答 2

2

Here you go: http://jsfiddle.net/jZVA2/

If I may suggest read the plugin again. http://bassistance.de/jquery-plugins/jquery-plugin-validation/ documentation http://docs.jquery.com/Plugins/Validation

Few things are missing:

  • Name tag
  • class required
  • Submit button type submit
  • script

Hope it fits your needs :)

code

$(document).ready(function() {
    $('#mainForm').validate();
});​

Bit complicated version here: http://jsfiddle.net/AvJNk/

<script type='text/javascript' src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"> </script>
于 2012-08-21T04:35:48.517 回答
0

您必须更改输入类型按钮才能提交并记住它适用于您的名称属性而不是您的 id,如下所示

<input type="text" name="mytxtName" id="mytxtId" />

会有这样的代码

$(document).ready(function() {
  $('#mainForm').validate({
     rules: {
     mytxtName: {
        required: true
     }
 }
});});

在此处检查工作代码...

于 2012-08-21T04:56:15.780 回答