The jQuery plugin for validation and post form data to server

Overview

NiceForm

The jQuery plugin for validation and post form data to server (http://ducdhm.github.io/jquery.niceform/)

Shortcuts

Dependencies

Rules

Name Selector Description
Required .required Invalid when value of field is blank or same as placeholder attribute
Date .date Invalid when value of field is not matched with locale.date format from configuration
Time .time Invalid when value of field is not matched with locale.time format from configuration
DateTime .datetime Invalid when value of field is not matched with locale.datetime format from configuration
Email .email Invalid when value of field is not matched with regex.email regular expression from configuration
Number .number Invalid when value of field is not number/digit/numeric
Url .url Invalid when value of field is not matched with regex.url regular expression from configuration
Password .password Invalid when value of field is not matched with password from configuration
Repassword .repassword Invalid when value of field is not matched with .password field
Regex .regex Invalid when value of field is not matched with data-regex regular expression from attribute of field. Error message of this rule will be specified in data-regex-message attribute
Regex .simple Invalid when value of field is not matched with regex.url regular expression from configuration
Regex .really-simple Invalid when value of field is not matched with regex.url regular expression from configuration

Note:

  • You can ignore validation rules by using data-ignore=validate for your fields
  • You can combined Required rule with other rules
  • All rules except Required will be validated if value of field is not blank

Configuration

Option Type Description
postFormEnabled Boolean Allow NiceForm post form data to server by using AJAX or not.
Default: true
postUrl String URL to post form data.
Default: null
ajax Object AJAX options to post form data
Default: { type: 'POST', dataType: 'JSON' }
password Object Password validator options.
Default: source code
regex Object Regular expression options.
Default: source code
animationDuration Number Animation duration in millisecond.
Default: 200
locale Object Locale options.
Default: source code
validate Function Function to validate the form fields which are not in built-in list. Need to return array of invalid fields or null if valid.
Default: null.
Params: form and options.
Return: `Array
showError Function Function to show error states when form is invalid.
Default: source code.
Params: form, errorFields and options
hideError Function Function to hide error states before validating form.
Default: source code.
Params: form, errorFields and options
processAjaxResponse Function Function to process ajax response from server to decide response is success or not.
Default: source code.
Params: resp, form, and options.
Return: Boolean
onValid Function Callback will be called when form is valid.
Default: null.
Params: form and options
onInvalid Function Callback will be called when form is invalid.
Default: null.
Params: form and options
onBeforeValidate Function Callback will be called before validating form.
Default: null.
Params: form and options
onBeforeSerializeForm Function Callback will be called before serializing form.
Default: null.
Params: form and options
onBeforePostForm Function Callback will be called before posting form.
Default: null.
Params: form and options
onAjaxSuccess Function Callback will be call if processAjaxResponse return true.
Default: source code.
Params: resp, form and options
onAjaxError Function Callback will be call if processAjaxError return false or $.ajax gets error or an unknown issue occurs.
Default: source code.
Params: jqXhr, form and options

Methods

Name Params (ParamType: paramName) Description
clearValue String: controlSelector Clear value, uncheck and set selected index is -1 of all text boxes, textareas, select boxes, radio buttons, checkboxes or provided controlSelector.
NOTE: Not effect with element data-ignore="clear"
enableForm Enable all form controls include textbox, textarea, select box, radio button, checkbox and button.
NOTE: Set readonly=false for all elements which do not contain data-origin-readonly
disableForm Disable all form controls include textbox, textarea, select box, radio button, checkbox and button.
NOTE: Set readonly=true and data-origin-readonly=true for elements which are readonly as default
showMessage String: type
String: title
String: message
Built-in message method of NiceForm. type can be success, info, warning, error or danger
showSuccessMessage String: message Shortcut of showMessage with type is success and title is Success!
showErrorMessage String message Shortcut of showMessage with type is error and title is Error!
hideMessage Hide built-in message
getOptions Get options/configuration of NiceForm
showElement jQuery: element Show specified element with fadeIn and slideDown effects
hideElement jQuery: element Hide specified element with fadeOut and slideUp effects

Note: There are many ways to call method

$('#form-id').niceform('methodName', param1, param2, ...);

or

var niceform = $('#form-id').niceform(options); // Get NiceForm instance when initializing
niceform.methodName(param1, param2, ...);

or

var niceform = $('#form-id').data('niceform'); // Get NiceForm instance via `data` attribute
niceform.methodName(param1, param2, ...);

Custom message

To custom message for a specified field, just need data-${rule}-message attribute. Example:

<input type="text" class="required email" name="email" data-required-message="Email address is mandatory!" data-email-message="Email address is invalid!" /> 

License

Please read at here

You might also like...

This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

leaderboad Description the project. this project is about the leaderboad i did during Microverse to build a website for adding Data to the API and fet

May 30, 2022

Easy server-side and client-side validation for FormData, URLSearchParams and JSON data in your Fresh app 🍋

Fresh Validation 🍋     Easily validate FormData, URLSearchParams and JSON data in your Fresh app server-side or client-side! Validation Fresh Validat

Dec 23, 2022

Simple and lightweight form validation for Svelte with no dependencies.

Svelidate Simple and lightweight form validation for Svelte with no dependencies Installation // npm npm install svelidate // yarn yarn add svelidate

Dec 28, 2022

A simple Form Validation Utility for Bootstrap 3, Bootstrap 4, and Bootstrap 5 for Humans.

A simple Form Validation Utility for Bootstrap 3, Bootstrap 4, and Bootstrap 5 for Humans.

bootstrap-validate A simple Form Validation Utility for Bootstrap 3, Bootstrap 4, and Bootstrap 5 for Humans. 🎉 Support us with Developer Merchandise

Jan 2, 2023

Javascript Library providing form validation helpers

Javascript-Form-Validation Javascript Library providing form validation helpers Table of contents Installation Usage Include Library Use components Co

Mar 25, 2022

Composition API & Yup Powered Form Validation

vue-yup-form Composition API & Yup Powered Form Validation. This tiny library allows Vue and Yup to be a best friend. Requirements The following versi

Dec 26, 2022

Picky is a jQuery plugin that provides simple client-side date validation when entering dates using select tags.

jquery.picky.js Picky is a jQuery plugin that provides simple client-side date validation when entering dates using select tags. Features Instead of g

Apr 25, 2021

This is a Google Apps Script library for parsing the form object from HTML form and appending the submitted values to the Spreadsheet.

This is a Google Apps Script library for parsing the form object from HTML form and appending the submitted values to the Spreadsheet.

HtmlFormApp Overview This is a Google Apps Script library for parsing the form object from HTML form and appending the submitted values to the Spreads

Oct 23, 2022

Auth-Form-Design - Beautiful Auth Form Designed using React 🥰.

Auth-Form-Design - Beautiful Auth Form Designed using React 🥰.

🙋 Auth Form Design 🥳 Features 1. Check Your Password Strength 2. Can Use Suggested Password 3. Enjoy Responsive Design Getting Started with Create R

Dec 24, 2022
Comments
  • Bump jquery from 3.4.1 to 3.5.0

    Bump jquery from 3.4.1 to 3.5.0

    Bumps jquery from 3.4.1 to 3.5.0.

    Commits
    • 7a0a850 3.5.0
    • 8570a08 Release: Update AUTHORS.txt
    • da3dd85 Ajax: Do not execute scripts for unsuccessful HTTP responses
    • 065143c Ajax: Overwrite s.contentType with content-type header value, if any
    • 1a4f10d Tests: Blacklist one focusin test in IE
    • 9e15d6b Event: Use only one focusin/out handler per matching window & document
    • 966a709 Manipulation: Skip the select wrapper for <option> outside of IE 9
    • 1d61fd9 Manipulation: Make jQuery.htmlPrefilter an identity function
    • 04bf577 Selector: Update Sizzle from 2.3.4 to 2.3.5
    • 7506c9c Build: Resolve Travis config warnings
    • Additional commits viewable in compare view
    Maintainer changes

    This version was pushed to npm by mgol, a new releaser for jquery since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump acorn from 6.3.0 to 6.4.1

    Bump acorn from 6.3.0 to 6.4.1

    Bumps acorn from 6.3.0 to 6.4.1.

    Commits
    • 9a2e9b6 Mark version 6.4.1
    • 90a9548 More rigorously check surrogate pairs in regexp validator
    • df0cf1a Mark version 6.4.0
    • 5303412 Also export Parser via Parser.acorn
    • efe273e give token types and etc to plugins
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Location of

    Location of "main" file in package.js

    Please add "main" file location as "main": "dist/jquery.niceform.js" in package.js otherwise it can't be required from the installed NPM package.

    Thank you.

    opened by ignaty 0
Releases(v1.0.9)
Owner
Duc Doan (Bobby)
A father, a husband and a JS geek :"3
Duc Doan (Bobby)
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Move all the disks from the left hand post to the right hand post, only moving the disks one at a time and a bigger disk can never be placed on a smaller disk.

Hanoi Tower Description The Tower of Hanoi was a famous problem posed by a mathematician in 1883, The "puzzle" is to move all the disks from the left

Dustin J Sellers 1 Feb 5, 2022
Form To CSS - jQuery-Plugin form to CSS generator

Create your own CSS generator with the form to css generator Builder plugin. Can be usefull to create your own css builder or a Wordpress plugin or any kind of apps you need a real time css generator. For example, you can create a button generator

Gino 4 Sep 26, 2021
A robust form library for Lit that enriches input components with easy-to-use data validation features.

EliteForms A robust form library for Lit that enriches input components with easy-to-use data validation features. Installation npm install elite-form

OSLabs Beta 33 Jun 28, 2022
✏️ A small jQuery extension to turn a static HTML table into an editable one. For quickly populating a small table with JSON data, letting the user modify it with validation, and then getting JSON data back out.

jquery-editable-table A small jQuery extension to turn an HTML table editable for fast data entry and validation Demo ?? https://jsfiddle.net/torrobin

Tor 7 Jul 31, 2022
RenderIf is a function that receives a validation as a parameter, and if that validation is true, the content passed as children will be displayed. Try it!

RenderIf RenderIf is a function that receives a validation as a parameter, and if that validation is true, the content passed as children will be disp

Oscar Cornejo Aguila 6 Jul 12, 2022
Disallow form tags without explicit method="post"

eslint-plugin-require-form-method-post Disallow form tags without explicit method="post" Prevents sensitive data appearing on URLs Allow form tags wit

Darwin Christopher Tantuco 2 Apr 24, 2022
A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again.

form-storage A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again. Installation via npm npm install

appleple 159 Dec 10, 2022