在表单有效时单击提交按钮后显示加载图像

时间:2013-08-05 01:32:58

标签: php javascript loader

我有一个非常基本的表单,如果表单有效,我想在点击提交按钮后显示加载图像,然后显示操作页面。以下是验证javascript的代码:

<script type="text/javascript">
function validateForm()
{
    valid = true;

    if(document.grades.fullName.value == "")
    {
        alert ("Please fill out your Full Name.");
        valid = false;
    }

    if(document.grades.idNo.value == "")
    {
        alert ("Please fill out your ID Number.");
        valid = false;
    }

    if(document.grades.pCS.value == "")
    {
        alert ("Please fill out your grade for Prelim Class Standing.");
        valid = false;
    }

    if(document.grades.pExam.value == "")
    {
        alert ("Please fill out your grade for Prelim Examination.");
        valid = false;
    }

    if(document.grades.mCS.value == "")
    {
        alert ("Please fill out your grade for Midterm Class Standing.");
        valid = false;
    }

    if ( document.grades.mExam.value == "" )
    {
        alert ("Please fill out your grade for Midterm Examination.");
        valid = false;
    }

    if(document.grades.fCS.value == "")
    {
        alert ("Please fill out your grade for Finals Class Standing.");
        valid = false;
    }

    if(document.grades.fExam.value == "")
    {
        alert ("Please fill out your grade for Finals Examination.");
        valid = false;
    }

    return valid;
}
</script>

请有人告诉我有多完整。

1 个答案:

答案 0 :(得分:1)

请替换,

return valid;

通过

if(valid)
{
  document.getElementById('display').style.display="block";
  return true;
}

在html中,

<div id="display" style="display:none;"><img src="{image_url}" /></div>