MVC4 remote validation not working properly
Date : March 29 2020, 07:55 AM
it helps some times Please, read this article, that gives a full explanation of how remote validation works. Pay special attention to this lines: if (valid)
{
return Json(true);
}
else
{
return Json("this is the error message");
}
|
Bootstrap remote validation not work properly with java
Date : March 29 2020, 07:55 AM
wish helps you the data your sending back to the bootstrap validator is not in correct json format. Change it to correct json format and I will work. This worked for me . Change it according to ur requirement public class RegistrationEmailCheck extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
JSONObject json = new JSONObject();
String availEmail = request.getParameter("email");
System.out.println(availEmail);
String SQL = "SELECT email FROM login WHERE email='" + availEmail + "'";
Connection con = DBInfo.getConn();
Statement st;
ResultSet rs;
try {
st = con.createStatement();
rs = st.executeQuery(SQL);
if (rs.next()) {
out.print("{\"valid\" : false }");
json.put("valid", false);
System.out.println("false");
} else {
out.print("{\"valid\" : true }");
json.put("valid", true);
System.out.println("true");
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
out.close();
}
}
}
|
Struts2 validation is not working properly, validation error messages not shown
Date : March 29 2020, 07:55 AM
wish of those help After having read how the INPUT result works and having abandoned the ModelDriven design pattern that adds nothing to your programming experience except problems, that might easily hide themselves in the middle of the Interceptor Stack, note that: redirect is the result to use when redirecting to external URLs or non-Action URLs, while redirectAction should be used when redirecting to an Action; when redirecting, a new request is created, and hence the old parameters (including action errors and messages and field errors) are lost.
|
Mobile number validation not working properly using jquery validation
Date : March 29 2020, 07:55 AM
should help you out I am using jQuery validation. I am using minlength:8 and maxlength:10 for a mobile number. , Using addMethod $(document).ready(function() {
$.validator.addMethod(
"mobileValidation",
function(value, element) {
return !/^\d{8}$|^\d{10}$/.test(value) ? false : true;
},
"Mobile number invalid"
);
$("#form").validate({
rules: {
mobile: {
required: true,
mobileValidation: $("#mobile").val(),
},
},
});
});
<script src="https://code.jquery.com/jquery-3.4.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.0/dist/jquery.validate.min.js"></script>
<form id="form">
<input type="number" id="mobile" name="mobile" />
<input type="submit" name="submit" value="submit" />
</form>
|
All jquery validation rules working properly (working onkeyup) but only confirm password validation working only after o
Date : March 29 2020, 07:55 AM
seems to work fine On registration form, all jquery validation rules working properly (working onkeyup) but only confirm password validation working only after onclick on submit button , You have problem in this line, <input type="Password" class="form-control" name="conf_password" id="conf_password"
placeholder="Confirm Password" value="<?=set_value('conf_password')?>">
<input type="password" class="form-control" name="conf_password"
id="conf_password" placeholder="Confirm Password" value="<?=set_value('conf_password')?>">
$.validator.setDefaults({
submitHandler: function() {
alert("submitted!");
}
});
$().ready(function() {
// validate the comment form when it is submitted
// validate signup form on keyup and submit
$("#signup").validate({
rules: {
password: {
required: true,
minlength: 4,
maxlength: 4,
digits: true
},
conf_password: {
required: true,
equalTo: "#mainpassword"
},
},
messages: {
password: {
required: "Password is required",
minlength: "Password should be a 4-digit number",
maxlength: "Password should be a 4-digit number",
digits: "Password should contain only numbers"
},
conf_password: {
required: "Confirm Password is required",
equalTo: "Password mismatch"
},
}
});
// propose username by combining first- and lastname
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://jqueryvalidation.org/files/dist/jquery.validate.js"></script>
<form class="cmxform" id="signup" name="signup" method="get" action="">
<fieldset>
<div class="form-group">
<label for="password" class="col-sm-4 control-label">Password :</label>
<div class="col-sm-8">
<input type="password" class="form-control" name="password" id="mainpassword" placeholder="Enter Password" value="">
</div>
</div>
<div class="form-group">
<label for="conf_password" class="col-sm-4 control-label">Confirm Password :</label>
<div class="col-sm-8">
<input type="password" class="form-control" name="conf_password" id="conf_password" placeholder="Confirm Password" value="">
</div>
</div>
<p>
<input class="submit" type="submit" value="Submit">
</p>
</fieldset>
</form>
|