1

我有一个非常基本的表单,如果表单有效,我想在单击提交按钮后显示加载图像,然后显示操作页面。这是验证的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>

请有人告诉我如何完全。

4

1 回答 1

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>
于 2013-08-05T03:49:02.740 回答