I am using html5 validation for my form in jsp page. I have given novalidate in form. When i click on submit button of that form it should validate the form now and display all validation in one label which was hidden before.How can i get these in jsp?
This is my form code.
<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>
I want to display all the validation notes after submitting the submit button.These validations should displaye in textfield which is given hidden here.how can i do that?
this is my code for not repeating the emailID. where should i put this in above form?How to display its validation in the textfield which is given hidden above?
<%
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();
}
%>
call demo() function in your JavaScript
and submit form by
return true
or
return false