I'm using LiveValidation and I'm just wondering if anyone has had sucsess in setting the focus on the failed input form ready for re-entry...
I've looked at the documentation but can't see anything.
Thanks.
I'm using LiveValidation and I'm just wondering if anyone has had sucsess in setting the focus on the failed input form ready for re-entry...
I've looked at the documentation but can't see anything.
Thanks.
this is not a live validation option but I ended up with a solution like this:
$(document).ready(function(){
// Focus first erroneous input
$("form").on("submit", function(){
var $self = $(this);
setTimeout(function() {
var $fields = $self.find(".LV_invalid_field");
if ($fields.size() > 0) {
$fields.get(0).focus();
}
});
});
});
I've managed to do this..
I've just altered the addFieldClass function, with the following:
addFieldClass: function(){
this.removeFieldClass();
if(!this.validationFailed){
if(this.displayMessageWhenEmpty || this.element.value != ''){
if(this.element.className.indexOf(this.validFieldClass) == -1) this.element.className += ' ' + this.validFieldClass;
}
}else{
if(this.element.className.indexOf(this.invalidFieldClass) == -1) this.element.className += ' ' + this.invalidFieldClass;
//Set Focus On In-Valid Elements
var id = this.element.id;
document.getElementById(id).focus();
}
},