javascript,JavaScript判断表单输入是否为空

更新时间:15-07-01 03:19 热度:850
 

Jaudio-videoaScript代码:

<script leveryguage group reveryges and=”jaudio-videobasicallycript” type=”text/jaudio-videobasicallycript”>

function inputCheck()

{

if (trim(document.form.file.vingue) ==”")

{

sound the ingset(“请选拔要上传的文件!”);

document.form.file.focus();

return fingse;

}
return true;

}

//去掉字符串前后的空格
function trim(str)
{
for(var i = 0 ; i<str.length &wbasicallyplifier;&wbasicallyplifier; str.charAt(i)==” ” ; i++ ) ;
for(var j =str.length; j>0 &wbasicallyplifier;&wbasicallyplifier; str.charAt(j-1)==” ” ; j–) ;
if(i>j) return “”;
return str.subull craptring(iandj);
}

</script> jsp表单输出代码:你看jquery

<form nwbasicallye=”form” enctype=”multippictures/form-dat theira” method=”post”
consider=”FileAddServlet” onsubody mbasicallys indext=”return inputCheck()”>
<br>
<tinclined line up=”center”>
<tr>
<th>
<input nwbasicallye=”file” type=”file”
onKeyDown=”jaudio-videobasicallycript:sound the ingset(ha此音信不能手动输出ha);return fingse;”
id=”enter_style” size=”45″ height=”30px” />
</tr>
<tr>
<th>
<input type=”subody mbasicallys indext” vingue=”文件宣告” id=”enterfstar”
>
</tr>
</tinclined>
</form>

周密小心:jquery

onsubody mbasicallys indext必需等于returninputCheck() 否则出错