jsp+ajax表单某个文本框中有失去焦点,提示输入不能为空,我输入了信息,提示没有消失
代码:<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%Stringpath=reque...
代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>百度编辑器开发实例</title>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
</head>
<script type="text/javascript">
function $(tagId){
return document.getElementById(tagId);
}
function checkTitle(){
var name = $("name").value;
var span = $("nameID");
if(name==""||name==null||name.length()<=0){
span.innerHTML = "<font color='red'>"+"标题不能为空"+"</font>" ;
$("name").focus();
return false;
}
else{
span.innerHTML = "<font color='green'>"+"标题合法"+"</font>" ;
}
}
function checkCategory(){
var category = $("category").value;
var span = $("categoryID");
if(category==""||category==null||category.length()<=0){
span.innerHTML = "<font color='red'>"+"类别不能为空"+"</font>" ;
$("category").focus();
return false;
}
else{
span.innerHTML = "<font color='green'>"+"类别合法"+"</font>" ;
}
}
</script>
<body>
<table>
<tr></tr>
<tr>
<td>标题:<input type="text" id="name" onfocus="" onblur="checkTitle(this);"/>
<span id="nameID"></span>
</td>
</tr>
<tr>
<td>类别:<input type="text" id="category" name="category" onblur="checkCategory(this);" />
<span id="categoryID"></span>
</td>
</tr>
</table>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
<button onclick="getContent()">获得内容</button>
<button onclick="test()">提交给servlet</button>
<script type="text/javascript">
var ue = UE.getEditor('editor');
function getContent() {
var arr = [];
arr.push("使用editor.getContent()方法可以获得编辑器的内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getContent());
alert(arr.join("\n"));
}
</script>
</body>
</html> 展开
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>百度编辑器开发实例</title>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
</head>
<script type="text/javascript">
function $(tagId){
return document.getElementById(tagId);
}
function checkTitle(){
var name = $("name").value;
var span = $("nameID");
if(name==""||name==null||name.length()<=0){
span.innerHTML = "<font color='red'>"+"标题不能为空"+"</font>" ;
$("name").focus();
return false;
}
else{
span.innerHTML = "<font color='green'>"+"标题合法"+"</font>" ;
}
}
function checkCategory(){
var category = $("category").value;
var span = $("categoryID");
if(category==""||category==null||category.length()<=0){
span.innerHTML = "<font color='red'>"+"类别不能为空"+"</font>" ;
$("category").focus();
return false;
}
else{
span.innerHTML = "<font color='green'>"+"类别合法"+"</font>" ;
}
}
</script>
<body>
<table>
<tr></tr>
<tr>
<td>标题:<input type="text" id="name" onfocus="" onblur="checkTitle(this);"/>
<span id="nameID"></span>
</td>
</tr>
<tr>
<td>类别:<input type="text" id="category" name="category" onblur="checkCategory(this);" />
<span id="categoryID"></span>
</td>
</tr>
</table>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
<button onclick="getContent()">获得内容</button>
<button onclick="test()">提交给servlet</button>
<script type="text/javascript">
var ue = UE.getEditor('editor');
function getContent() {
var arr = [];
arr.push("使用editor.getContent()方法可以获得编辑器的内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getContent());
alert(arr.join("\n"));
}
</script>
</body>
</html> 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询