一个HTML的简单问题

来源:百度知道 编辑:UC知道 时间:2024/06/28 10:51:19
我正在用HTML编写一个用户注册界面,要求ID、密码这些不能为空,在点击提交按钮时检查这些文本框是否为空,具体我不会实现,具体代码怎么写,是写在文本框部分还是按钮部分,我是新手请尽量说详细
还有,在点击按钮的同时还要验证密码和重复密码是否一样,具体代码怎样写,谢谢~分数可以追加~
很急~在线等~

<script>
function checkform(){
var mytext=document.myform.mytext.value;
if(mytext==""){
if(confirm('内容为空,是否继续?')){
window.location.href="html2.htm";
}else{
document.myform.mytext.focus();
}
return false;
}else{
return true;
}
}
</script>
<form name="myform" method="post" onsubmit="return checkform()">
<input type="text" name="mytext" value="">
<input type="submit" name="mybut" value="提交">
</form>