Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-validation

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-validation

Client-side form validation made easy

  • 1.15.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
148K
decreased by-10.44%
Maintainers
2
Weekly downloads
 
Created

What is jquery-validation?

The jquery-validation npm package is a popular plugin for the jQuery library that provides a simple way to validate forms on the client side. It offers a wide range of validation rules and customization options to ensure that user input meets the required criteria before submission.

What are jquery-validation's main functionalities?

Basic Form Validation

This feature allows you to set up basic form validation rules. In this example, the field 'fieldName' is required and must be at least 2 characters long. Custom error messages are also provided.

$(document).ready(function() {
  $("#myForm").validate({
    rules: {
      fieldName: {
        required: true,
        minlength: 2
      }
    },
    messages: {
      fieldName: {
        required: "This field is required",
        minlength: "Your input must be at least 2 characters long"
      }
    }
  });
});

Custom Validation Methods

This feature allows you to define custom validation methods. In this example, a custom rule 'customRule' is created to ensure that the input contains only letters.

$.validator.addMethod("customRule", function(value, element) {
  return this.optional(element) || /^[a-zA-Z]+$/.test(value);
}, "Please enter only letters");

$(document).ready(function() {
  $("#myForm").validate({
    rules: {
      fieldName: {
        customRule: true
      }
    }
  });
});

Remote Validation

This feature allows you to perform remote validation by making an AJAX request to the server. In this example, the 'username' field is validated against a server endpoint to check if the username is already taken.

$(document).ready(function() {
  $("#myForm").validate({
    rules: {
      username: {
        required: true,
        remote: "/check-username"
      }
    },
    messages: {
      username: {
        required: "Please enter a username",
        remote: "Username is already taken"
      }
    }
  });
});

Other packages similar to jquery-validation

Keywords

FAQs

Package last updated on 22 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc