您的位置:首页 > Web前端 > JavaScript

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息