Some basic javascript usage
2004-11-24 19:12
387 查看
In modern page design, JavaSricpt is quit important to do some input check at Client side.
In the comp231 project, we want to build a library management system based on Web, so JavaScript is used
Here I do some summary:
1. check whether the input of a form is Empty or not:
<SCRIPT LANGUAGE="JavaScript">
<!--
{
if(form.name.value.length==0)
alert("input empty");
else
form.submit();
}
//-->
</SCRIPT>
here, form is the name of the <form> and name is the text of pass name, in this check() the situation that all spaces in name can't be detected.
2. check whether the input is a Number or not
<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
if(isNaN(aaform.aa.value))
alert("input is not a number");
else
alert("input is a number");
}
//-->
</SCRIPT>
3 check whether a checkbox is checked
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkb()
{
if(myform.mycheckbox.check)
alert("checkd");
else
alert("not checked");
}
//-->
</SCRIPT>
In the comp231 project, we want to build a library management system based on Web, so JavaScript is used
Here I do some summary:
1. check whether the input of a form is Empty or not:
<SCRIPT LANGUAGE="JavaScript">
<!--
{
if(form.name.value.length==0)
alert("input empty");
else
form.submit();
}
//-->
</SCRIPT>
here, form is the name of the <form> and name is the text of pass name, in this check() the situation that all spaces in name can't be detected.
2. check whether the input is a Number or not
<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
if(isNaN(aaform.aa.value))
alert("input is not a number");
else
alert("input is a number");
}
//-->
</SCRIPT>
3 check whether a checkbox is checked
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkb()
{
if(myform.mycheckbox.check)
alert("checkd");
else
alert("not checked");
}
//-->
</SCRIPT>
相关文章推荐
- JavaScript封装的常用工具类库bee.js用法详解【经典类库】
- VC与Delphi之间动态链接库互相调用
- ATL实现Connection Point的一种简单的方法
- OpenOffice,好用的开源办公软件
- javascript表单之间的数据传递!
- PHP 的 MySQL 操作类,跟手册上的函数一样用,但是更方便了。多说无益,看了就知道了。
- delphi中的时间操作技术(1)
- delphi中的时间操作技术(2)
- VB五子棋问题,请高手赐教
- IP地址的隐藏(delphi实现 )
- GMAT简介
- 解析IP地址为主机域名
- 将某一主机域名解析为IP地址
- Struts tags (4) ----Html(2)
- 有关TrueDBGrid的问题向各位大虾请教
- 用VB和MTS开发多层数据库应用系统