Hi guys i have registration form designed in bootstrap where i have validate all the form fileds using remote validator and i have registerdao.java method which has checkusername boolean method which checks all the rows and if username exists it returns username string otherwise false and i have checkusernameexists method in registartiion servlet which checks username when you enter username fields.I don't understand why my code is not showing anything.Below is the code is not checking username against database and notifying.How to write javascript so that it checks the username against data or give me some ideas how to make this code work? any help would be greatly appreaciated?thanks
ReegisterDao.java public static boolean checkUserName(String userName) throws SQLException{ String checkUserNameQuery = "select * from EmployeeDetails where USER_NAME='"+userName+"'";
try{
// preparing some objects for connection
currentCon = ConnectionManager.getConnection();
Statement stmt = currentCon.createStatement();
rs = stmt.executeQuery(checkUserNameQuery);
boolean more = rs.next();
// if user does not exist set the isValid variable to false
return more;
}
catch (InstantiationException | IllegalAccessException e){}
return false; }
RegistrationServlet.java
public int checkUserNameExists(RegistrationBean user) throws SQLException{
int a=RegistrationDao.Register(user);
return a;
}
this is part of remote validator which validates username
username: {
validators: {
notEmpty: {
message: 'The username is required'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
message: 'The username can only consist of alphabetical, number, dot and underscore'
},
remote:{
message:'This Username is already taken',
url:'https://localhost:8080/RegistrationServlet.java',
data:'username'
},
type:'POST'
}
},
and this is part of bootstrap username fields
<div class="form-group">
<label class="col-xs-2 control-label">Username</label>
<div class="col-xs-4">
<input type="text" class="form-control" name="username" placeholder="Username" />
</div></div>