<script language="JavaScript">
function Popup(url, window_name, window_width, window_height)
{ settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height; NewWindow=window.open(url,window_name,settings); }function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script><title>论坛</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function CheckValue()//检查标题内容是否为空值
{
var name=document.all.name.value;
var re=/( )/gi
name=name.replace(re,"")
re=/\</gi
name=name.replace(re,"<")
if(name==""||name.length<1)
{
alert("用户名不能为空");
document.all.name.focus();
return false;
}
document.all.name.value=name;
TheText=document.all.email.value;
var re=/( )/gi
TheText=TheText.replace(re,"")
if(TheText=="")
{
alert("内容不能为空");
document.all.email.focus();
return false;
} if (form1.mobile.value!="")
{
if(checkNumber1(form1.mobile.value)==false)
return false;
}
if (form1.oicq.value!="")
{
if(checkNumber2(form1.oicq.value)==false)
return false;
}
return true;
}function checkNumber1(TempS)
{
for(Count=0;Count<TempS.length;Count++)
{
TempChar=TempS.substring(Count,Count+1);
RefString="0123456789";
if (RefString.indexOf(TempChar,0)==-1)
{
alert("手机号码有非法字符,请输入数字");
form1.mobile.focus();
return false;
}
}
}
function checkNumber2(TempS)
{
for(Count=0;Count<TempS.length;Count++)
{
TempChar=TempS.substring(Count,Count+1);
RefString="0123456789";
if (RefString.indexOf(TempChar,0)==-1)
{
alert("OICQ有非法字符,请输入数字");
form1.oicq.focus();
return false;
}
}
}function Popup(url, window_name, window_width, window_height)
{ settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height; NewWindow=window.open(url,window_name,settings); }function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script>还有一个问题,为什么该JSP文件的最后非要加个
<html><script language="JavaScript"></script></html>?有何用意
function Popup(url, window_name, window_width, window_height)
{ settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height; NewWindow=window.open(url,window_name,settings); }function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script><title>论坛</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function CheckValue()//检查标题内容是否为空值
{
var name=document.all.name.value;
var re=/( )/gi
name=name.replace(re,"")
re=/\</gi
name=name.replace(re,"<")
if(name==""||name.length<1)
{
alert("用户名不能为空");
document.all.name.focus();
return false;
}
document.all.name.value=name;
TheText=document.all.email.value;
var re=/( )/gi
TheText=TheText.replace(re,"")
if(TheText=="")
{
alert("内容不能为空");
document.all.email.focus();
return false;
} if (form1.mobile.value!="")
{
if(checkNumber1(form1.mobile.value)==false)
return false;
}
if (form1.oicq.value!="")
{
if(checkNumber2(form1.oicq.value)==false)
return false;
}
return true;
}function checkNumber1(TempS)
{
for(Count=0;Count<TempS.length;Count++)
{
TempChar=TempS.substring(Count,Count+1);
RefString="0123456789";
if (RefString.indexOf(TempChar,0)==-1)
{
alert("手机号码有非法字符,请输入数字");
form1.mobile.focus();
return false;
}
}
}
function checkNumber2(TempS)
{
for(Count=0;Count<TempS.length;Count++)
{
TempChar=TempS.substring(Count,Count+1);
RefString="0123456789";
if (RefString.indexOf(TempChar,0)==-1)
{
alert("OICQ有非法字符,请输入数字");
form1.oicq.focus();
return false;
}
}
}function Popup(url, window_name, window_width, window_height)
{ settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height; NewWindow=window.open(url,window_name,settings); }function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script>还有一个问题,为什么该JSP文件的最后非要加个
<html><script language="JavaScript"></script></html>?有何用意
解决方案 »
- 求解 事务权限问题
- Struts2 如何返回上一页并刷新?
- 关于初始页面的信息查询问题
- 怎么才算是一个WEB应用?怎么才算是一个对话?
- Sun今日发布Java 2 Platform, Enterprise Edition 5.0
- Eclipse使用lomboz插件+jboss调试时,是不是必须先把项目deploy到jboss中才能调试?
- j2eesdk 的 问题?
- 紧急求救:取数据库中字段值为中文字符时的乱码(此问题都不知道问了多少次,也不知在多少个论讨中发表过,但是还是没有人帮我解决)
- 问一个很菜的问题,如果想做EJB的话,都需要什么东西,必需要borland的Application Server
- 如何将两个集合转换为list<map>类型的
- 通过jsp,servlet实现动态的报表统计图
- 谁能提供一下哪里可以下载到电气java软件源码?
javaScript是执行在客户端,即平时我们说的浏览器上script language="JavaScript"
这里说的是语言版本是按javaScript执行
我的JSP文件整体结构是这样的
<html>
<script language="JavaScript">
...
</script>
</html>
<html> <script language="JavaScript"> </script> </html>
留意着最后一行,是否多余?以及那个说过script为JS了。是多余的吧?
第二个方法是给 document.input.message.value message文本框赋值下面的两个方法是检验手机号码是不是数字还有一个问题,为什么该JSP文件的最后非要加个
<html> <script language="JavaScript"> </script> </html>?有何用意
这个是多余的
function Popup(url, window_name, window_width, window_height)//定义一些消息窗口的属性:如toolbar,location,status等
{ settings=
"toolbar=no,location=no,=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"=yes,width="+window_width+",height="+window_height;NewWindow=window.open(url,window_name,settings); }//建立个消息窗口function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script><title>论坛 </title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function CheckValue()//
{
var name=document.all.name.value;
var re=/( )/gi //创建正则表达式定义一些字符
name=name.replace(re,"")//将name中包含的上面定义的字符给替代成"",即删去
re=/\ </gi
name=name.replace(re,"<")//同上
if(name==""||name.length <1)
{
alert("用户名不能为空");
document.all.name.focus();
return false;
}
document.all.name.value=name;
TheText=document.all.email.value;
var re=/( )/gi
TheText=TheText.replace(re,"")
if(TheText=="")
{
alert("内容不能为空");
document.all.email.focus();
return false;
} if (form1.mobile.value!="")
{
if(checkNumber1(form1.mobile.value)==false)
return false;
}
if (form1.oicq.value!="")
{
if(checkNumber2(form1.oicq.value)==false)
return false;
}
return true;
}function checkNumber1(TempS)//检查手机号码的有效性,Temps为传入的手机号码
{
for(Count=0;Count <TempS.length;Count++)//循环手机号码截取字符
{
TempChar=TempS.substring(Count,Count+1);//一段段截取,如输入手机号码为1324523,那么它依次截取的字符为1,3,2,4,5,2,3
RefString="0123456789";//定义手机号码输入的格式只能为数字
if (RefString.indexOf(TempChar,0)==-1)//将截取的字符进行格式校验,如出现非数字则运行if里面的代码
{
alert("手机号码有非法字符,请输入数字");
form1.mobile.focus(); //输入重新聚焦
return false;
}
}
}
function checkNumber2(TempS)//同上
{
for(Count=0;Count <TempS.length;Count++)
{
TempChar=TempS.substring(Count,Count+1);
RefString="0123456789";
if (RefString.indexOf(TempChar,0)==-1)
{
alert("OICQ有非法字符,请输入数字");
form1.oicq.focus();
return false;
}
}
}
function Popup(url, window_name, window_width, window_height)//同上
{ settings=
"toolbar=no,location=no,directories=no,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+window_width+",height="+window_height;NewWindow=window.open(url,window_name,settings); }function icon(theicon) {
document.input.message.value += " "+theicon;
document.input.message.focus();
}
</script>
最后的一句是多余的;一个网页文件里面只能存在一个<html></html>组,多了不解析或者出错!