我创建了一个表单,我希望用户在点击并验证完成后运行我的文件。我在验证正确时放了一个脚本来禁用提交按钮并提交表单。我遇到的问题是它确实进行了验证并禁用了按钮,但它没有提交我的值。当我删除该函数并使用默认的spry验证时,我没有问题,只有禁用代码。
表格
<form action="toolsprocess.php" method="get" id = "myForm" name="myForm" >
<span style="font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#052347; font-weight:600;">Area Name</span><br />
<span id="spryareaname">
<input name="name" type="text" id="name" size="30" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#052347; font-weight:600; border-radius:5px; height:30px;"//>
<span class="textfieldRequiredMsg">*</span></span>
<span id="spryselectoffice">
<select name="office" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#052347; font-weight:600; border-radius:5px; height:30px;" >
<option value="-1">Select a Office</option>
<?php
$sql_one="SELECT
office.id
, office.office
, franchise.Franchise
FROM
franchise
INNER JOIN office
ON (franchise.id = office.franchise_fk);";
$result_set_one=mysql_query($sql_one);
while($row=mysql_fetch_assoc($result_set_one)){
$proj_name=$row['office']." - ".str_replace(".","",$row['Franchise']);
$proj_id = $row['id'];
echo '<option value='.$proj_id.'>'.$proj_name.'</option>';
}
?>
</select>
<span class="selectInvalidMsg">*</span><span class="selectRequiredMsg">*</span></span>
<input type="hidden" name="process" value="process_areas" /><input type="submit" name="button2" id="button2" value="Submit" onclick="javascript:validateonsubmit();" />
</form>
<script type="text/javascript">
function validateonsubmit()
{
var myForm = document.getElementById("myForm");
var spryareaname = new Spry.Widget.ValidationTextField("spryareaname");
var spryselectoffice = new Spry.Widget.ValidationSelect("spryselectoffice", {invalidValue:"-1"});
var SS = Spry.Widget.Form.validate(myForm);
if(SS == true){
document.getElementById("button2").disabled = true;
document.getElementById("button2").value = "Submitting.....";
myForm.submit();
}
else
{
document.getElementById("button2").disabled = false;
}
}
</script>