Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert when tab on age

I got multiple 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 tabbing through the fields, how can I set an alert when focused on the age field?

like image 348
Becky Avatar asked Dec 25 '22 06:12

Becky


1 Answers

You can use focus event:

$("input[name = 'age']").focus(function() {
  alert( "focused on age inputbox." );
});
like image 185
Dhara Parmar Avatar answered Jan 09 '23 13:01

Dhara Parmar