javaScript中怎样获取textarea中的值
解决方案 »
- 下面JAVA代码是不是用MD5对数据库SQL SERVER用户密码加密的?帮忙详细注释每一行代码。
- 如何用过滤器把非法的文字替换成指定的文字?
- struts2下,一个action可以在多个路径访问,如何禁止??
- 如何发布JAVA WEB项目(做过开发的发言,复制的免贴)
- 如何配置tomcat读取struts-config文件
- #####郁闷之极的javaBean问题######
- 如何从数据库读取数据导出到Excel,然后保存到本地机器(有点急,请伸援手)
- JSP有没有上传文件的组件啊
- 多选的下拉菜单
- logback 根据日志大小进行切割 设置MaxFileSize没有生效
- 这样的错误:Column Index out of range, 5 > 4。实在查不出,高手看看
- jsp网页运行问题,请教中^本人使用asp,望能得到支持100分
form1为form名称
textAreaName为textarea的名称。
document.form1.textAreaName.value 我试了不行的。
有个字母小写了,你不会直接抄的吧
if(document.getElementById("text1").value==""){
alert("本评价讨论区不能发表空留言!");
return false;
}
return true;
}
用了啊,还是不行呢?
<textarea id="xxxx" ...
text1要和你id的值一样
</textarea>
javascript:
function publish(){
if(document.getElementById("text1").value==""){
alert("本评价讨论区不能发表空留言!");
return false;
}
return true;
}
怎样你应该看清楚了吧?请高手解决
<title>this is a test</title>
<script lang="javascript">function publish(){
alert('in');
alert(document.getElementById("text1").value.length); if(document.getElementById("text1").value==''){ alert("本评价讨论区不能发表空留言!");
return false;
} return true;
}
</script>
<body><FORM NAME="myForm">
<textarea id="text1" name="content" cols="20" rows="20"></textarea><input name="button2" type="button" value="Show Form Elements"
onClick="publish()">
</FORM> The alert dialog box displays the following text:
</body>
</html>
我试了下,可以阿,你报什么错了?
document.all.text1.value
<head>
<script language="javascript">
function show()
{
alert(document.form1.demo.value);
}
function show2()
{
alert(document.getElementById("demo").value);
}
function show3()
{
alert(document.forms[0].demo.value);
}
</script>
</head>
<body>
<form name="form1">
<input type=text name=text readonly=readonly value="asfasdf"><br>
<textarea id="demo" name="demo" cols="15" rows="5">test</textarea>
<input type=button onclick="show();return true;" value=show1>
<input type=button onclick="show2();return true;" value=show2>
<input type=button onclick="show3();return true;" value=show3>
</form>
</body>
</html>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page session="true" %>
<%
session.putValue("enter","true");
%>
<html>
<title>新的主题</title>
<HEAD>
<script language="JavaScript">
function checkdata(){ if(document.forms[0].subject.value==""){
alert("本论坛主题不能为空!");
return false;
}
if(document.forms[0].content.value==""){
alert("本论坛不能发表空留言!");
return false;
}
return true;
}
</script>
</HEAD>
<body bgcolor="#DEF3CE">
<%@include file="../inc/session.inc"%>
<%@include file="../inc/rq.inc"%>
<center>
<table width="600" border="0" cellspacing="0" bgcolor="#DEF3CE" bordercolor="white" align="center">
<tr align="center" bgcolor="#DEF3CE">
<td width=60% align=left><font size=2 color=blue><b>【新的主题】</b></font></td>
<td width=40% align=left><font size=2 color=red><a href=discuss_brows.jsp><font size=2>回论坛看板</font></a>
</font></td></tr>
</table>
<hr size=1 width=80% color=red>
<table border=0>
<form action=savemain.jsp method=post OnSubmit="return checkdata()">
<tr><td align=left><font size=2>作者[<%=user%>] 部门[<%=dep%>] [日期]<%=rq%><%=time%></font></td></tr>
</table>
<hr size=1 width=80% color=white>
<table>
<input type=hidden size=40 name=bm value=<%=dep%>>
<input type=hidden size=40 name=name value=<%=user%>>
</tr>
<tr><td><font size=2>主题</font></td><td ><input type=text size=60 id=subject name=subject></td></tr>
<tr><td valign=top ><font size=2>内容</font></td><td><textarea id="content" name="content" rows=10 cols=60></textarea></td></tr>
</table>
<table>
<tr align=center><td calign=center olspan=2><input type=submit name=send value=确定><input type=reset name=reset value=清除></td></tr>
</table>
<hr size=1 width=80% color=red>
</form>
</body>
</html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
function alertTextareaText() {
var value=document.form.textarea.value;
alert(value);
}
//-->
</script>
</head><body>
<form method=post action="" name="form">
<textarea name="textarea" rows="10" cols="60"></textarea>
<input type="button" value="测试" onclick="alertTextareaText();">
</form>
</body>
</html>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page session="true"%>
<%session.putValue("enter", "true");
%>
<html>
<title>新的主题</title>
<HEAD>
<script language="JavaScript">
function checkdata(){ if(document.forms[0].subject.value==""){
alert("本论坛主题不能为空!");
return false;
}
if(document.forms[0].content.value==""){
alert("本论坛不能发表空留言!");
return false;
}
return true;
}
</script>
</HEAD>
<body bgcolor="#DEF3CE">
<%@include file="../inc/session.inc"%>
<%@include file="../inc/rq.inc"%>
<center>
<table width="600" border="0" cellspacing="0" bgcolor="#DEF3CE"
bordercolor="white" align="center">
<tr align="center" bgcolor="#DEF3CE">
<td width=60% align=left><font size=2 color=blue><b>【新的主题】</b></font></td>
<td width=40% align=left><font size=2 color=red><a
href=discuss_brows.jsp><font size=2>回论坛看板</font></a> </font></td>
</tr>
</table>
<hr size=1 width=80% color=red>
<form action=savemain.jsp method=post OnSubmit="return checkdata()">
<table border=0> <tr>
<td align=left><font size=2>作者[<%=user%>] 部门[<%=dep%>] [日期]<%=rq%><%=time%></font></td>
</tr>
</table>
<hr size=1 width=80% color=white>
<table>
<input type=hidden size=40 name=bm value=<%=dep%>>
<input type=hidden size=40 name=name value=<%=user%>>
</tr>
<tr>
<td><font size=2>主题</font></td>
<td><input type=text size=60 id=subject name=subject></td>
</tr>
<tr>
<td valign=top><font size=2>内容</font></td>
<td><textarea id="content" name="content" rows=10 cols=60></textarea></td>
</tr>
</table>
<table>
<tr align=center>
<td calign=center olspan=2><input type=submit name=send value=确定><input
type=reset name=reset value=清除></td>
</tr>
</table>
<hr size=1 width=80% color=red>
</form>
</body>
</html>
这样试下
document.all["textArea的id"].value,这样怎么都可以取到textare中的值了.