function check(){
if (document.news.title.value == "") {
alert ("请输入标题名") ;
document.news.title.focus() ; //set focus
return false ;
}
if (document.news.username.value == ""){
alert ("请输入你的用户名称") ;
document.news.username.focus() ;
return false ;
}
if (document.news.password.value == "") {
alert ("请输入您的密码") ;
document.news.password.focus() ;
return false ;
}
if (document.news.authortype.value == "0") {
alert ("选择单位") ;
document.news.authortype.focus() ;
return false ;
}
if (document.news.newstype.value == "0") {
alert ("选择类别") ;
document.news.newstype.focus() ;
return false ;
}
}
if (document.news.title.value == "") {
alert ("请输入标题名") ;
document.news.title.focus() ; //set focus
return false ;
}
if (document.news.username.value == ""){
alert ("请输入你的用户名称") ;
document.news.username.focus() ;
return false ;
}
if (document.news.password.value == "") {
alert ("请输入您的密码") ;
document.news.password.focus() ;
return false ;
}
if (document.news.authortype.value == "0") {
alert ("选择单位") ;
document.news.authortype.focus() ;
return false ;
}
if (document.news.newstype.value == "0") {
alert ("选择类别") ;
document.news.newstype.focus() ;
return false ;
}
}
调用:
<form name="news" method="post" action="{* $action *}" enctype="multipart/form-data"
onSubmit="return check();"> </form>