清照39度浓香型价格:怎样用javascript验证表单???

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 23:51:46
只输入空格[不管多少]不能提交,怎么实现?是否要用正则表达式?请提供一下这段javascript代码,谢谢!!!!!!!![对javascript正则表达式不太懂]

<scriptlanguage="javascript">
function strtrim()
{
vartheform=document.trimform;
trimedname=theform.name.value;
vartrimed_name=trimedname.replace("","");
alert("您输入的内容是:\""+trimed_name+"\"");
return false;//视具体的使用情况决定是否用该句;
}
</script>

使用这个方法,详细:
<html>
<head>
<scriptlanguage="javascript">
function strtrim(){
vartheform=document.trimform;
trimedname=theform.name.value;
vartrimed_name=trimedname.replace("","");
alert("您输入的内容是:\""+trimed_name+"\"");
returnfalse;//视具体的使用情况决定是否用该句;
}
</script>
</head>

<body>
<formmethod="post"action=""onsubmit="return strtrim()" name="trimform">
<inputtype="text" name="name">
<inputtype="submit"name="Submit" value="TestTrimed" class="font">
</form>
</body>
</html>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>用户登录</title>
</head>

<body>

<SCRIPT LANGUAGE="JavaScript">
function pass()
{
var user1="test"
var user2="test"var pass1=document.myform.password.value
var user10=document.myform.user.value
if (pass1 == user2&&user10==user1)
{alert("成功登录...欢迎你")
document.write("<HTML>")
document.write("<body bgcolor='#fef4d9'>")
document.write("<center><p><font size='6'color='darkblue'>欢迎进入!!</p>")
document.write("<p><a href='index2.htm'>进入</a><br>")
document.write("</html>")}
else
{
alert("登录失败")}
}
function change()
{
document.bgColor=('#fef4d9')
}
</SCRIPT>
<font color="red">
<center>
<FORM name="myform">
<h3>用户登录</h3>
用户名:
<INPUT TYPE="text"name="user">
<br>
密码:
<input type="password"name="password">
<br>
<input type="button"Value="进入"onClick="pass()">
<input type="button"value="重置">
</form>
</body>

</html>

要想知道密码,wey524@126.com

要用正则表达是