I have a function to draw n inputs
this is the reason of why my inputs do not have ID
, I use the following function to validate the typed value on every input after unfocus
:
$('#Div').on('blur', '.inputbtn', function () {
validarType.bind(this)();
});
function validarType() {
var xd = this.value;
if (xd != "") {
bootbox.confirm({
message: "Value: " + xd + " is correct?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (result) {
if (result == true) {
}
else {
bootbox.alert("Check your data.");
//Focus Here
}
}
});
}
else {
}
}
What I want to do is for example type information on the first input, after change focus to other input alert message is going to appear, if I click on No
option I want to focus that input again, but like I said, I do not have any ID
to do something like $('#Myinput').focus()
in other case maybe could be possible do this with '$(this).focus()'
, what can I do?
Here is a Codepen Example