How to Check If an Input Field is Empty Using jQuery

  8537 views   2 years ago jQuery

Use the jQuery val() Method

You can use the val() method to test or check if inputs are empty in jQuery.

The following example will add a red outline around the inputs if it is focused but not filled out.

<!DOCTYPE html>
<html lang="en">
<title>Check If Inputs are Empty using jQuery</title>
        outline: 1px solid red;
<script src=""></script>
    $('#myForm input[type="text"]').blur(function(){
        } else{
    <form id="myForm">
        <p><label>First Name: <input type="text"></label></p>
        <p><label>Last Name: <input type="text"></label></p>
        <p><label>Email Address: <input type="text"></label></p>


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]