Check empty input with jquery

Check empty input with jquery

Check empty input with jquery

HI

this is my code for checking bs3 form input fields, not working. can I get help?

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <style>
    .text-label {
            color: dodgerblue;
            font-weight: bold;
   }
  </style>
  <script>

// Bind the event handler to the "submit" JavaScript event $('.yourname').click(function(){

// Get the Login Name value and trim it
var name = $('#yourname').val();

// Check if empty of not
if (name.length &lt; 1) {
    alert('Text-field is empty.');
    return false;
}

});

</script> <!-- https://stackoverflow.com/questions/16556968/jquery-form-submit-to-check-empty-fields --> </head> <body>

<div class="container"> <h2>Vertical (basic) form</h2> <form class="login"> <div class="form-group"> <label for="yourname">Your Name:</label> <input type="email" class="form-control" id="yourname" placeholder="Enter name" name="name"> </div> <div class="form-group"> <label for="email">Email:</label> <input type="email" class="form-control" id="email" placeholder="Enter email" name="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd"> </div> <div class="checkbox"> <label><input type="checkbox" name="remember"> Remember me</label> </div> <button class="btn btn-success">Submit</button> </form> </div>

</body> </html>


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Understand and Use JavaScript's .forEach() vs. jQuery's .each()

There are two functions to deal with an array on the client-side – JavaScript's .forEach() and jQuery's .each(). Here, I will teach you how to use both of these methods with some sample code.

jQuery vs Vanilla JavaScript - Beau teaches JavaScript

When should you use jQuery instead of vanilla JavaScript? Is jQuery still relevant? What is jQuery good for? jQuery vs vanilla JavaScript - Beau teaches JavaScript

3 JavaScript libraries to replace jQuery

Ubiquitous jQuery has been outmoded by JavaScript and browser advances. Cash, Zepto, and Syncfusion are three JavaScript libraries picking up where jQuery left off