Warn when tabbing by age
I received several forms. I have 5 text fields.
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname"br>
Last name:<br>
<input type="text" name="lastname""><br>
Age:<br>
<input type="text" name="age"br>
State:<br>
<input type="text" name="state"br>
Profession:<br>
<input type="text" name="profession"br><br>
<input type="submit" value="Submit">
</form>
While the user is moving through the fields, how to set up an alert when focused on the field age?
While the user is moving through the fields, how can I set a warning when focused on the age field?
Other answers do not answer this question. The OP wants to show a warning only when tabbing across fields and when focusing a field age.
$(':text').eq($(':text[name="age"]').index('form :text')).on('keyup', function (e) {
if (e.keyCode === 9) {
setTimeout(function () {
alert('Focused');
});
}
});
$(':text').eq($(':text[name="age"]').index('form :text')).on('keyup', function (e) {
if (e.keyCode === 9) {
setTimeout(function () {
alert('Focused');
});
}
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="action_page.php">
First name:
<br>
<input type="text" name="firstname" br> Last name:
<br>
<input type="text" name="lastname">
<br> Age:
<br>
<input type="text" name="age" br> State:
<br>
<input type="text" name="state" br> Profession:
<br>
<input type="text" name="profession" br>
<br>
<input type="submit" value="Submit">
</form>Hi, kindly check https://jsfiddle.net/snvurmez/ you need to use the focus () function
JQuery
$(document).ready(function(){
$("input[name='age']").on('focus', function(){
alert('focus on age tab');
});
});