jQuery Articles

Page 2 of 42

How to validate a form using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 16-Mar-2026 32K+ Views

To validate a form using jQuery, we can use the jQuery Validation Plugin. This plugin provides a simple way to define validation rules, custom error messages, and submit handlers for HTML forms without writing complex validation logic from scratch. The plugin works by attaching the .validate() method to a form element and defining rules for each input field by its name attribute. Syntax The basic syntax for jQuery form validation is − $(document).ready(function() { $("#formId").validate({ rules: { ...

Read More

How to check input file is empty or not using JavaScript/jQuery?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 9K+ Views

In JavaScript, while working with the form elements, we need to validate the input fields and form elements when a user enters the value. In this tutorial, we will work with the file input. We will also learn to validate the file input. Sometimes, we may be required to check if the file is selected in the input field, then only enable the submit button; otherwise, disable the submit button. So, it will not allow users to submit the form or file without selecting it. Validate the file input using JavaScript In JavaScript, we can access the ...

Read More

How to Check a String Starts/Ends with a Specific String in jQuery?

Ayushya Saxena
Ayushya Saxena
Updated on 15-Mar-2026 969 Views

JavaScript provides several built-in methods to check if a string starts or ends with specific characters. While jQuery is excellent for DOM manipulation, these string operations are handled by native JavaScript methods that work efficiently without any additional library. In this article, we'll explore various approaches to verify if a string begins or ends with another string using practical examples. Using startsWith() Method The startsWith() method is the most direct way to check if a string begins with specific characters. It's case-sensitive and returns a boolean value. Syntax str.startsWith(searchString, position) Parameters ...

Read More

How to Change an HTML Element Name Using jQuery?

Aayush Mohan Sinha
Aayush Mohan Sinha
Updated on 15-Mar-2026 1K+ Views

jQuery is a JavaScript library created to make event handling, CSS animation, Ajax, and DOM tree navigation and manipulation easier. In this article we are going to see how we can change the name of an element using jQuery. Algorithm We are going to follow a three−way procedure to change the name of any element using jQuery: Identify and select the element we want to change. Copy all the attributes of the selected element to a temporary object. Create a new element with the ...

Read More

How to set textarea scroll bar to bottom as a default using JavaScript/jQuery?

Gungi Mahesh
Gungi Mahesh
Updated on 15-Mar-2026 3K+ Views

In JavaScript, you can set a textarea's scroll bar to the bottom using the scrollTop property. This is useful when you want to automatically show the most recent content, such as in chat applications or log displays. Syntax element.scrollTop = element.scrollHeight; Parameters scrollHeight − Returns the total height of the element's content, including content not visible due to overflow. Method 1: Using Pure JavaScript This approach uses the DOM's scrollTop property to position the scroll bar at the bottom of the textarea. ...

Read More

How to check two elements are the same using jQuery/JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 2K+ Views

We can access HTML elements using various methods in vanilla JavaScript or jQuery. Sometimes, after accessing DOM elements, developers need to check if both accessed elements are the same or not. In this tutorial, we will learn to use JavaScript's strict equality operator and jQuery's is() method to check the equality of two HTML elements. Using the Equality Operator (===) in JavaScript We can access HTML elements using methods like getElementById, querySelector, getElementsByClassName, etc. After storing elements in JavaScript variables, we can compare them using the strict equality operator (===). Syntax if (element1 === element2) ...

Read More

Use jQuery to get values of selected checkboxes?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 509 Views

jQuery provides an efficient way to get values of selected checkboxes using the :checked selector combined with checkbox input elements. This is useful for forms where users can select multiple options. Syntax $('input[type="checkbox"]:checked') // or $('input[name="checkboxName"]:checked') Basic Example Here's a complete example that demonstrates getting values of selected checkboxes: jQuery Checkbox Values Select your hobbies: ...

Read More

How to add content in section using jQuery/JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Adding content to the section dynamically is useful for loading CSS, JavaScript, or meta tags after page load. jQuery and JavaScript provide several methods to accomplish this task programmatically. There are three main approaches to add content to the head section: Using jQuery's .append() method Using JavaScript's document.createElement() method Using JavaScript's insertAdjacentHTML() method Let's explore each approach with working examples. Using jQuery's .append() Method jQuery's append() method provides a simple way to add content to the head section: ...

Read More

Add sizes for Bootstrap Buttons

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 318 Views

Bootstrap provides several CSS classes to control button sizes, from large buttons to block-level buttons that span the full width of their container. Button Size Classes Class Description .btn-lg ...

Read More

How to fire after pressing ENTER in text input with HTML?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 538 Views

There are several ways to detect when the ENTER key is pressed in a text input field. Here are the most common and effective approaches. Using jQuery with Custom Event This approach creates a custom "enterKey" event that triggers when ENTER is pressed: $(document).ready(function(){ $('input').bind("enterKey", function(e){ ...

Read More
Showing 11–20 of 413 articles
« Prev 1 2 3 4 5 42 Next »
Advertisements