在一个好的项目中,它应该是这样的:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#form-signup').yiiActiveForm({
"username": {
"validate": function(attribute, value, messages) {
yii.validation.required(value, messages, {
"message": "Username\u4e0d\u80fd\u4e3a\u7a7a\u3002"
});
yii.validation.string(value, messages, {
"message": "Username\u5fc5\u987b\u662f\u4e00\u6761\u5b57\u7b26\u4e32\u3002",
"min": 2,
"tooShort": "Username\u5e94\u8be5\u5305\u542b\u81f3\u5c112\u4e2a\u5b57\u7b26\u3002",
"max": 255,
"tooLong": "Username\u53ea\u80fd\u5305\u542b\u81f3\u591a255\u4e2a\u5b57\u7b26\u3002",
"skipOnEmpty": 1
});
},
"id": "signupform-username",
"name": "username",
"validateOnChange": true,
"validateOnType": false,
"validationDelay": 200,
"container": ".field-signupform-username",
"input": "#signupform-username",
"error": ".help-block"
},
</script>
但是在我的项目中,当我输入无效的电子邮件或用户名时,没有提示或错误显示!当我检查 yii 生成的代码时,我看到 yiiActiveForm 的 null args
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#form-signup').yiiActiveForm([], []);
});
</script>
谁能告诉我为什么?供应商文件夹有什么问题吗?