You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Rick, Trying to check valid zip from database using custom validation rule of an input field on blur.
Here is what I am trying,
validator.registerCallback('check_validpincode', function(value) {
if (checkValidPincode(value)) {
return true;
}
return false;
}).setMessage('check_validpincode', 'The Pin Code is invalid.');
In the remote call section :
function checkValidPincode(val)
{
getNewAjaxResult(val).done(function(d) {
$("._ztoken").val(d.token);
$('#pincode').removeClass('loading');
if(d.valid == 1){
return true;
}
else {
return false;
}
})
.fail(function(x){
return false;
});
}
function getNewAjaxResult(val)
{
// Show the ajax "In progress" spinner
// Check from Pin Code records, whether the pincode is valid
// If found, return true --> else return false
//var arg = 'pincode='+val;
var req_path = "./home/checkvalidpincode";
var csrfName = $("._ztoken").attr("name");
var csrfHash = $("._ztoken").val(); // CSRF hash
return $.ajax({
url: req_path,
type:'POST',
dataType: 'json',
data: {"pin":val, [csrfName]:csrfHash},
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {'X-Requested-With': 'XMLHttpRequest'},
beforeSend: function() {
$('#pincode').addClass('loading');
}
});
}
I am not able to get the return value from the validator function.
Can you please help?
The text was updated successfully, but these errors were encountered:
Hi Rick,
Trying to check valid zip from database using custom validation rule of an input field on blur.
Here is what I am trying,
validator.registerCallback('check_validpincode', function(value) {
if (checkValidPincode(value)) {
return true;
}
return false;
}).setMessage('check_validpincode', 'The Pin Code is invalid.');
In the remote call section :
function checkValidPincode(val)
{
getNewAjaxResult(val).done(function(d) {
$("._ztoken").val(d.token);
$('#pincode').removeClass('loading');
if(d.valid == 1){
return true;
}
else {
return false;
}
})
.fail(function(x){
return false;
});
}
function getNewAjaxResult(val)
{
// Show the ajax "In progress" spinner
// Check from Pin Code records, whether the pincode is valid
// If found, return true --> else return false
//var arg = 'pincode='+val;
var req_path = "./home/checkvalidpincode";
var csrfName = $("._ztoken").attr("name");
var csrfHash = $("._ztoken").val(); // CSRF hash
return $.ajax({
url: req_path,
type:'POST',
dataType: 'json',
data: {"pin":val, [csrfName]:csrfHash},
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {'X-Requested-With': 'XMLHttpRequest'},
beforeSend: function() {
$('#pincode').addClass('loading');
}
});
}
I am not able to get the return value from the validator function.
Can you please help?
The text was updated successfully, but these errors were encountered: