The focusout() method in jQuery is used to remove the focus from the selected element. Now we will use focusout() method to validate the input field while focussing out. This method checks whether the input field is empty or not. Also, use some CSS property to display input field validation. If the input field is empty then it will display the red border input field otherwise display green border input field.
Example 2: Validation alert if input field empty using siblings(), addClass() method.
- How to validate and sanitize user input with PHP?
- HTML | Clearing the input field
- JQuery | Set the value of an input text field
- How to detect value change on hidden input field in JQuery ?
- How to disable browser Autocomplete on web form field/input tag?
- JQuery | Set focus on a form input text field on page load
- jQuery | focusout() with Example
- How to validate an Email using PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.