I have got the following scenario: I am using boostrap validator and more specifically - callback validator on form field. What is specific for the callback validator is that it returns true / false.
Within the callback validator, I have to to check for username availability on server side. Unfortunately remote validator is not an option, since I am sending message to server via socket, using build in sendServerMessage command. To be more specific see code snippet from my callback validator:
callback: function(name, validator, $field) {
.....
function nameCheckHandler(msgType, msgData) {
// callback for returning result from the server
if(msgData.roomStatus === "taken") {
// ----> this is where I have got the result and and can return. How to manage it???
}
else if(msgData.roomStatus === "available") {
// ----> this is where I have got the result and and can return. How to manage it???
}
myServer.sendServerMessage("msgNameCheck", {username: name}, nameCheckHandler, function(){});
}
So my question is - given the above snippet - if it possible, how to return true/false
value to callback validator?