我有一個表單的javascipt函數。該代碼是:Javascript驗證多個功能?
<script type="text/javascript">
function verify() {
if (isNaN(document.form1.exp_amount.value) == true) {
alert("Invalid Block Amount");
return false;
} else if ((document.form1.exp_name.value).length == 0) {
alert("Block Exp is left Blank!");
return false;
} else if ((document.form1.exp_amount.value).length == 0) {
alert("Block Amount is left Blank!");
return false;
} else {
document.form1.submit();
return true;
}
}
</script>
,現在我必須爲它提供字母驗證,我有它在單獨的JS功能:
<script language="javascript" >
function checkName() {
re = /^[A-Za-z]+$/;
if (re.test(document.exp_name.form1.value)) {
alert('Valid Name.');
} else {
alert('Invalid Name.');
}
}
</script>
如果我想有字母驗證內部功能驗證() ..我怎麼能這樣做?或者還有其他方法嗎?
你有沒有想過你的縮進代碼? – ThiefMaster 2011-03-24 07:26:26