jQuery Validate验证框架 + CKEditor 无法验证问题的解决方法
2012-02-23 14:42
676 查看
在jQuery Validate总是验证不通过,原因就是在 CKEditor 编辑器填写了内容之后,编辑器并不是立即把内容更新到原来的 textarea 元素中的
可以在提交表单之前进行如下修改
CKEDITOR.instances.content.updateElement();
html标签为:
<textarea class="ckeditor" name="content" rows="4" cols="30"></textarea>
完整html代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${contextPath}/scripts/validate/jquery.validate.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="${contextPath}/scripts/jquery-1.4.4.js"></script>
<script type="text/javascript" src="${contextPath}/scripts/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="${contextPath}/scripts/validate/jquery.validate.js"></script>
<script>
var valdater;
jQuery(document).ready(function(){
valdater=jQuery("#form").validate({
errorPlacement: function(error, element) {
error.appendTo( element.siblings("span"));
},
meta:"validate",
rules:{
content:{
required: true
}
},
messages:{
content:{required:'<s:text name="label.input.message_cn_content" />'} }
});
});
function doSubmit(){
CKEDITOR.instances.content.updateElement();
if(valdater.form()){
document.notice_form.submit();
return true;
}
return false;
}
</script>
</head>
<body id="fbody">
<div id="iframe_warp">
<form name="notice_form" id="form" action="${contextPath}/operator/message_add.action" method="post">
<textarea class="ckeditor" name="content" rows="4" cols="30"></textarea</s:form>
<input type="button" class="s_button" onclick="return doSubmit();" value="<s:text name="label.submit" />"></input>
</form>
</body>
</html>
可以在提交表单之前进行如下修改
CKEDITOR.instances.content.updateElement();
html标签为:
<textarea class="ckeditor" name="content" rows="4" cols="30"></textarea>
完整html代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${contextPath}/scripts/validate/jquery.validate.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="${contextPath}/scripts/jquery-1.4.4.js"></script>
<script type="text/javascript" src="${contextPath}/scripts/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="${contextPath}/scripts/validate/jquery.validate.js"></script>
<script>
var valdater;
jQuery(document).ready(function(){
valdater=jQuery("#form").validate({
errorPlacement: function(error, element) {
error.appendTo( element.siblings("span"));
},
meta:"validate",
rules:{
content:{
required: true
}
},
messages:{
content:{required:'<s:text name="label.input.message_cn_content" />'} }
});
});
function doSubmit(){
CKEDITOR.instances.content.updateElement();
if(valdater.form()){
document.notice_form.submit();
return true;
}
return false;
}
</script>
</head>
<body id="fbody">
<div id="iframe_warp">
<form name="notice_form" id="form" action="${contextPath}/operator/message_add.action" method="post">
<textarea class="ckeditor" name="content" rows="4" cols="30"></textarea</s:form>
<input type="button" class="s_button" onclick="return doSubmit();" value="<s:text name="label.submit" />"></input>
</form>
</body>
</html>
相关文章推荐
- 【转载】jQuery Validate验证框架 + CKEditor 无法验证问题的解决方法
- 『转载』jQuery Validate验证框架 + CKEditor 无法验证问题的解决方法
- jQuery Validate验证框架 + CKEditor 无法验证问题的解决方法
- 用JQuery Validate框架,在IE8下验证报错问题解决
- 关于引入多个jquery冲突的问题(附一个很好用的validate前端验证框架及使用方法)
- jQuery.get、jQuery.getJSON、jQuery.post无法返回JSON问题的解决方法
- 加验证控件无法提交的问题解决方法
- 0.jquery 验证,以及显示出现错误的地方 1.当用jquery.validate与ajax时候特别小心在每句后面的逗号问题,如果不需要的地方加上逗号会造成页面无法进入js验证
- 解决jquery中动态新增的元素节点无法触发事件问题的两种方法
- jquery validate验证框架与kindeditor使用问题
- jQuery Validate验证框架详解(封装jQuery Validate扩展验证方法)
- ckeditor4.1.1在jquery ui dialog(模式化窗口)中无法编辑,解决方法!
- Jquery validation remote 验证的缓存问题解决方法
- jquery 和其他js框架同时使用的不兼容问题解决方法
- EF框架:“无法更新EntitySet“*****”,因为它有一个DefiningQuery,而元素中没有支持当前操作的元素”问题的解决方法
- jquery checkbox无法用attr()二次勾选问题的解决方法
- 解决jquery无法找到其他父级子集问题的方法
- jQuery validate插件,自动验证无效的原因及解决方法归纳
- jQuery Validate验证表单时多个name相同的元素只验证第一个的解决方法
- jQuery.get、jQuery.getJSON、jQuery.post无法返回JSON问题的解决方法