2014-08-30 161 views
0

這是我的JSP頁面:HTML表單提交空值

<%@ page language="java" contentType="text/html; charset=utf-8" 
pageEncoding="ISO-8859-1"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" 
    content="text/html;charset=utf-8" /> 
    <title>Entry Form</title> 
    <link href="../css_res/style.css" rel="stylesheet" type="text/css" media="screen" /> 
    </head> 
    <body> 
    <div id="MongoFORM"> 
     <h1>Add New Entries To Database</h1> 
     <form action='../restful-services/errorops/PUSH2DB' onsubmit='this.submit();this.reset();return false;' method="post"> 
      <fieldset> 
       <label for="ErrorName">Error Name:</label> 
       <input required type="text" name="ErName" id="ErrorName" placeholder="Enter the Error Name" /> 

       <label for="ErrorCause">Error Cause:</label> 
       <input required type="text" name="ErCause" id="ErrorCause" placeholder="Enter generic cause" /> 

       <label for="ErrorResolution">Error Resolution:</label> 
       <input required type="text" name="ErResolution" id="ErrorResolution" placeholder="Enter generic resolution" /> 

       <label for="TechnicalDat">Technical Data:</label> 
       <input required type="text" name="TlDat" id="TechnicalDat" placeholder="Enter error code base info (JSON)" /> 
       <br> 
       <br> 
       <input type="submit" class="large default" value="POST TO DB!" /> 
      </fieldset> 
     </form> 
    </div> 

    </body> 
    </html> 

我的問題是,當我在POST點擊到數據庫!按鈕,空值被提交。然而,當onsubmit ='this.submit(); this.reset(); return false;'選項已刪除。任何人都可以請指導我解決問題嗎?

+1

發佈javascript代碼也 – 2014-08-30 16:47:23

回答

0

onsubmit()在表單提交之前運行,所以表單在提交前重置