我的代码如下:<script language="javascript">
<!--
function Tijiao()
{
if(document.form1.title.value=="")
{
alert("请输入标题");
form1.title.focus();
return false;
}
if(document.form1.name.value=="")
{
alert("请输入作者名称");
form1.name.focus();
return false;
}
if(document.form1.source.value=="")
{
alert("请输入信息来源");
form1.source.focus();
return false;
}
if(document.form1.RQ.value=="")
{
alert("请输入日期");
form1.RQ.focus();
return false;
}
//-->
</script><form name="form1" action="" method="post" onSubmit="return Tijiao();"> <textarea id="elm1" name="contents" class="$('#elm1').xheditor({tools:'simple'});" style="width:500px; height:200px;"></textarea></form>
1、使用判断文本域的话,提示不为空,但是输入内容后点击提交,会提示为空,如果在提交一次,才能添加上内容。
在js里添加的代码如下: if(document.form1.contents.value=="")
{
alert("请输入内容");
return false;
}
2、上网查到的,使用下面的代码,可是不起作用。
if (editor.getSource =="")
{
alert("留言内容不能为空!");
editor.getSource.focus();
return false;
}
return true;
}谁帮帮我看看呀。从昨天就找解决,头疼死我了。快帮帮我吧!!
<!--
function Tijiao()
{
if(document.form1.title.value=="")
{
alert("请输入标题");
form1.title.focus();
return false;
}
if(document.form1.name.value=="")
{
alert("请输入作者名称");
form1.name.focus();
return false;
}
if(document.form1.source.value=="")
{
alert("请输入信息来源");
form1.source.focus();
return false;
}
if(document.form1.RQ.value=="")
{
alert("请输入日期");
form1.RQ.focus();
return false;
}
//-->
</script><form name="form1" action="" method="post" onSubmit="return Tijiao();"> <textarea id="elm1" name="contents" class="$('#elm1').xheditor({tools:'simple'});" style="width:500px; height:200px;"></textarea></form>
1、使用判断文本域的话,提示不为空,但是输入内容后点击提交,会提示为空,如果在提交一次,才能添加上内容。
在js里添加的代码如下: if(document.form1.contents.value=="")
{
alert("请输入内容");
return false;
}
2、上网查到的,使用下面的代码,可是不起作用。
if (editor.getSource =="")
{
alert("留言内容不能为空!");
editor.getSource.focus();
return false;
}
return true;
}谁帮帮我看看呀。从昨天就找解决,头疼死我了。快帮帮我吧!!
解决方案 »
- 求一个判断混合四则运算js正则表达式
- 怎么扒JS?
- 设置Div滚动条总在最下
- 模态窗口showModelessDialog,子页面可否刷新???
- checkbox某一个值的 disabled问题,在线等,求教
- 求助:Javascipt中得到的四个方向键的键值是多少?
- 怎样在保持原form内容的同时动态地加入一些其他元素(input,select等等)
- 关于多页面之间操作问题
- 如何使用Javascript关闭非Javascript打开的窗口 急!!急!!急!!
- Object 的 Attribute 和 Properties 有什么不同?
- 不会js,js高手大师哥哥姐姐妹妹弟弟全上来
- 文本框和选择框判断的问题
function doCheck(){ if ($('#mycontent').val() == "" ){
alert("内容不能为空!");
return false;
}
}
我测试过可以判断的!