Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 正在验证我的表单_Javascript_Validation_Jsp - Fatal编程技术网

Javascript 正在验证我的表单

Javascript 正在验证我的表单,javascript,validation,jsp,Javascript,Validation,Jsp,我正在尝试验证我的表单,它是jsp格式的,但它没有发生!!它运行正常,但我没有调用javascript文件中的validatemark函数 这是我的密码: <%@ page import = "javax.servlet.http.HttpServlet" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&g

我正在尝试验证我的表单,它是jsp格式的,但它没有发生!!它运行正常,但我没有调用javascript文件中的validatemark函数

这是我的密码:

    <%@ page import = "javax.servlet.http.HttpServlet" %>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import= "org.akash.java.DabManager" %>
    <%@ page import= "org.akash.java.GetsSets" %>
    <%@ page import= "java.sql.ResultSet" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script type="text/javascript" src="ValidateMark.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>FILL IN YOUR MARKS HERE</title>

     </head>
     <body>
    <form action="MarksServlet" method="post" name="SubjectMarks" onsubmit="return(validatemark());" >

    <table cellpadding="2" width="20%" bgcolor="maroon" align="center"
    cellspacing="2">

        <tr>
            <td colspan=2>
            <center><font size=4><b>Subject Marks Form</b></font></center>
            </td>
        </tr>





     <%
     String stid= request.getParameter("identity");
     %>

     </tr>

        <tr>
            <td>ID</td>
            <td><input type="text" name="iden" id="iden" size="10" value= <%=stid %>></td>
        </tr>





     <tr>
        <td>Name</td>

            <%

            try {

        ResultSet resu= null;
        DabManager dab= new DabManager();
        resu= dab.Getsname(stid);
         if(resu.next())
         {
            String sname= resu.getString("sname");      
        %>
        <td><input type="text" name="yourname" id="yourname" size="30" value=<%=sname %>></td>
        <%
         }
        }catch(Exception e)
        {
            e.printStackTrace();
        }
       %>

        </tr>

        <tr>
            <td>Physics</td>
            <td><input type="text" name="Physics" id="Physics" size="10"></td>
        </tr>

        <tr>
            <td>Chemistry</td>
            <td><input type="text" name="Chemistry" id="Chemistry" size="10"></td>
        </tr>

        <tr>
            <td>Mathematics</td>
            <td><input type="text" name="Maths" id="Maths" size="10"></td>
        </tr>

        <tr>
            <td>Biology</td>
            <td><input type="text" name="Biology" id="Biology" size="10"></td>
        </tr>

        <tr>
            <td>
                <input type="reset">
            </td>
            <td colspan="2">
                <input type="submit" value="Submit Form" onclick ="confirms()"/>
            </td>
        </tr>
    </table>
</form> 

</body>
</html>

    function validatemark()
{
    if( document.SubjectMarks.iden.value == "" || isNaN( document.SubjectMarks.iden.value))
       {
         alert( "Please provide a valid id!" );
         document.SubjectMarks.iden.focus() ;
         return false;
       }
       if( document.SubjectMarks.yourname.value == "" )
       {
         alert( "Please provide your Name!" );
         document.SubjectMarks.yourname.focus() ;
         return false;
       }


       if( document.SubjectMarks.Physics.value == "" || isNaN(document.SubjectMarks.Physics.value)|| document.SubjectMarks.Physics.value >100)
       {
         alert( "Please enter valid marks!!" );
         document.SubjectMarks.Physics.focus() ;
         return false;
       }

       if( document.SubjectMarks.Chemistry.value == "" || isNaN(document.SubjectMarks.Chemistry.value)|| document.SubjectMarks.Chemistry.value >100)
       {
         alert( "Please enter valid marks!!" );
         document.SubjectMarks.Chemistry.focus() ;
         return false;
       } 

       if( document.SubjectMarks.Maths.value == "" || isNaN(document.SubjectMarks.Maths.value)|| document.SubjectMarks.Maths.value >100)
       {
         alert( "Please enter valid marks!!" );
         document.SubjectMarks.Maths.focus() ;
         return false;
       } 

       if( document.SubjectMarks.Biology.value == "" || isNaN(document.SubjectMarks.Biology.value)|| document.SubjectMarks.Biology.value >100)
       {
         alert( "Please enter valid marks!!" );
         document.SubjectMarks.Physics.focus() ;
         return false;
       } 

       return true;
}


function confirms()
{
    if(validatemark()== true)
     alert("Marks Entered Successfully");
}
onsubmit="return(validatemark());"
onsubmit=" return validatemark();"