1

我在 jsp 页面中对我的表单使用 html5 验证。我已经给出了 novalidate 的形式。当我单击该表单的提交按钮时,它现在应该验证表单并在一个之前隐藏的标签中显示所有验证。我怎样才能在 jsp 中获得这些?这是我的表单代码。

<form action="#join1_form" method="POST">
  <div>
    <input type="text" name="firstname" id="firstname" value="" required placeholder="First Name" pattern="\w+" />
    <input type="text" name="lastname" id="lastname" value="" required placeholder="Last Name" pattern="\w+" />
  </div>
  <div>
    <input type="email" name="email" placeholder="Your Email" id="email" value="" required />
  </div>
  <div>
    <input name="password" id="password" type="password" required placeholder="New Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="password" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Password must contain at least 6 characters, including UPPER/lowercase and numbers' : '');
if(this.checkValidity()) form.cpassword.pattern = this.value;">
  </div>
  <div>
    <input name="cpassword" id="cpassword" type="password" placeholder="Re-enter Password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="cpassword" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Please enter the same Password as above' : '');">
  </div>
  <div>
    <input type="label" hidden value="">
  </div>
  <input type="submit" value="Next">
</form>

我想在提交提交按钮后显示所有验证注释。这些验证应该显示在此处隐藏的文本字段中。我该怎么做?

这是我不重复 emailID 的代码。我应该把它放在上面的哪里?如何在上面隐藏的文本字段中显示它的验证?

<%
Connection conn = null;
PreparedStatement ps=null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "");
String email1=request.getParameter("lemail");
try{
  String q="SELECT * FROM userdetails where email=?";
  ps=conn.prepareStatement(q);
  ps.setString(1,email1);
  rs=ps.executeQuery();
  if(rs.next())
  {
    //what to do here?
  }
  else
  {
    //what to do here?
  }
}
catch(Exception e)
{
  e.printStackTrace();
}
try{
  if(ps!=null){
    ps.close();
  }
  if(rs!=null){
    rs.close();
  }
  if(conn!=null){
    conn.close();
  }
}
catch(Exception e)
{
  e.printStackTrace();
}
%>     
4

1 回答 1

1
<html:form action="storenotes" onsubmit="return demo()">

在 JavaScript 中调用 demo() 函数并通过 return true 或 return false 提交表单

于 2013-02-08T05:49:29.427 回答