关于javascript和ajax的问题!

来源:百度知道 编辑:UC知道 时间:2024/05/04 07:36:41
function ValidateForms(){
var x=new Date();
var y = document.frmSample.dateTo.value;
var z = document.frmSample.dayoffid.value;

result = y.split("-");
x.setDate(result[2]);
x.setMonth(result[1]-1);
x.setFullYear(result[0]);
s=x.toDateString()
s=s.substring(0,3)

if( s == 'Sat' && z ==3)
{
alert("Your selected date is Holidays!")
return false;
}

if( s == 'Sat') {
document.getElementById('firstone').style.display = 'inline';
document.getElementById('secondone').style.display = 'none';
}
}

<html>...
<form name="frmSample" ACTION = commit_leave.php METHOD = POST action="" onSubmit="return ValidateForm() && ValidateForms()">
Date To:
<input id="exampleII" name="dateTo" type="text" style="width: 115px;" m

<html>

<head>

<title></title>

</head>

<body>
<script language="javascript" type="text/javascript">
function yunxing(obj)
{
if (obj.value!="")
{
alert("运行改代码");
}
}

</script>
<input type="text" onblur="yunxing(this);">
<select onchange="yunxing(this);">
<option></option>
<option value="123">123</option>
<option value="456">456</option>
</select>
</body>

</html>

在那个input的Onchange中调用ValidateForms()函数,
而不是在Form的OnSubmit中调用

onchange="ValidateForms()"
不行的话改成onkeyup=ValidateForms()