All Projects → zaneray → scrupulous

zaneray / scrupulous

Licence: GPL-2.0 License
Simple inline form validation using HTML5 attributes that plays nicely with Bootstrap

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to scrupulous

js-form-validator
Javascript form validation. Pure JS. No jQuery
Stars: ✭ 38 (+216.67%)
Mutual labels:  validation, forms
Nice Validator
Simple, smart and pleasant validation solution.
Stars: ✭ 587 (+4791.67%)
Mutual labels:  jquery-plugin, validation
Liform React
Generate forms from JSON Schema to use with React (& redux-form)
Stars: ✭ 167 (+1291.67%)
Mutual labels:  validation, forms
Play2 Html5tags
HTML5 form tags module for Play Framework
Stars: ✭ 101 (+741.67%)
Mutual labels:  validation, forms
conditionize.js
Small jQuery plugins for handling conditional form fields via data attributes. Unmaintained.
Stars: ✭ 56 (+366.67%)
Mutual labels:  jquery-plugin, forms
Vue Formulate
⚡️ The easiest way to build forms with Vue.
Stars: ✭ 1,947 (+16125%)
Mutual labels:  validation, forms
Svelte Forms Lib
📝. A lightweight library for managing forms in Svelte
Stars: ✭ 238 (+1883.33%)
Mutual labels:  validation, forms
Laravel Multistep Forms
Responsable Multistep Form Builder for Laravel
Stars: ✭ 76 (+533.33%)
Mutual labels:  validation, forms
Ziptastic Jquery Plugin
This is a jQuery plugin that shows how Ziptastic could be used.
Stars: ✭ 244 (+1933.33%)
Mutual labels:  jquery-plugin, forms
Uploader
A lightweight and very configurable jQuery plugin for file uploading using ajax(a sync); includes support for queues, progress tracking and drag and drop.
Stars: ✭ 1,042 (+8583.33%)
Mutual labels:  jquery-plugin, forms
React Native Merlin
🧙 Simple web-like forms in react native.
Stars: ✭ 83 (+591.67%)
Mutual labels:  validation, forms
react-form-validation-demo
React Form Validation Demo
Stars: ✭ 88 (+633.33%)
Mutual labels:  validation, forms
React Inform
Simple controlled forms with validations in react
Stars: ✭ 81 (+575%)
Mutual labels:  validation, forms
Validation
Framework agnostic validation library for PHP
Stars: ✭ 146 (+1116.67%)
Mutual labels:  validation, forms
Wtforms
A flexible forms validation and rendering library for Python.
Stars: ✭ 1,214 (+10016.67%)
Mutual labels:  validation, forms
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+104875%)
Mutual labels:  validation, forms
Awesomevalidation
Android validation library which helps developer boil down the tedious work to three easy steps.
Stars: ✭ 1,093 (+9008.33%)
Mutual labels:  validation, forms
Form Object
Form object to use with Vue components for sending data to a Laravel application using axios.
Stars: ✭ 73 (+508.33%)
Mutual labels:  validation, forms
Form2js
Javascript library for collecting form data
Stars: ✭ 630 (+5150%)
Mutual labels:  jquery-plugin, forms
intl-tel-input-rails
intl-tel-input for the Rails asset pipeline
Stars: ✭ 35 (+191.67%)
Mutual labels:  jquery-plugin, validation

Scrupulous

Scrupulous.js is super simple, client side, inline form validation using HTML5 attributes. Add all the standard HTML5 form attributes and call the plugin and it will automatically add inline validation with full styleable elements and class names. View the demo here.

Scrupulous.js is built around Bootstrap, using the same class name and HTML structure for simple implementation. Not using Bootstrap? No problem, just update the class names in the CSS file and with minor changes it should still work fine.

#Setup

  • scrupulous.css: you will need to include the scrupulous.css which adds some additional styling to the form elements.

  • jQuery: Scrupulous should work with most newer versions of jQuery, Have not tested how far back it is supported

  • scrupulous.js: Runs a jQuery plugin.

  • Call the $.scrupulous() plugin on the form(s) you would like to validate.

      $(function(){
      	$('.validate-form').scrupulous();	
      });
    

##HTML Then just add standard HTML5 attributes to your form and Scrupulous takes care of the rest.

<form class="validate-form" method="post" action="/">
	<div class="form-group">
		<label for="email">Email</label>
		<input type="email" class="form-control" id="email" name="email" title="Please Enter a Valid Email Address" required>
    </div>
</form>

Note that the title of the field becomes the error message, mimmicking the default browser HTML5 validation messaging.

##HTML with Errors

If an error is detected the resulting HTML is generated dynamically.

<div class="form-group has-error">
	<label for="name">Name</label>
	<input type="text" class="form-control invalid" id="name" name="name" title="Please Enter a Name" required>
	<label class="error-message" for="name">Please Enter a Name</label>
</div>

##Valid HTML

When the form validates the following HTML is generated dynamically

<div class="form-group has-success">
	<label for="name">Name</label>
	<input type="text" class="form-control valid" id="name" name="name" title="Please Enter a Name" required>
</div>

#Additional Validation Methods There are additional validation methods that come in handy that can be controlled by data attributes.

data-equal-to:
ID of an element to check whether the values of the two elements are equal. Example is password fields where you want to make sure that both passwords match.

###Example The data-equal-to attribute value is the id of the first password field.

Password
Repeat Password

#Optional Properties More properties to be added as new features are needed.

valid:
A Callback if the form is valid. Must return true or false. Helpful if you are relying on another service to validate the form after the scrupulous script has determined the form. Examples: Credit Card Validation, Address Verification, Username Verification.
invalid:
Callback if the form is invalid. Always prevents form submission. Helpful if you need added functionality such as showing a global message above the form.
setErrorMessage:
Helper function used to set up custom error messaging. Helpful for cases where special messaging is needed for specific error modes.
errorClassName:
Default: 'error-message'. Customize the class name of error messages, useful when integrating into an existing project that does not use Bootstrap.
parentClassName:
Default: 'form-group'. Customize the class name of the parent container of the form element, useful when integrating into an existing project that does not use Bootstrap.
defaultErrorMessage:
Default: 'This field has an error'. Message display in the error label if no title tag is provided on the input element with an error.

###Example Example showing valid and invalid callbacks and setErrorMessage helper function


  $('.callback-form').scrupulous({
    valid: function(){
      alert('Valid Callback - Submit the Form');
      return true;
    },
    invalid: function(){
      alert('Invalid Callback -  Stop the Form');
      return false;
    },
    setErrorMessage: function(el){
      
      /** example to put custom message on inputs with type='number' **/
      var input = $(el);
      var message = null;
      var tag = el.tagName.toLowerCase();
      var type = ( tag == "input" ) ? input.attr("type").toLowerCase() : ( tag == "select" ) ? "select" : "unknown";
      
      /** use different messages if input value is too large vs too small **/
      if ( type == "number" ) {
        if (typeof input.attr("max") !== 'undefined' && input.attr("max") < input.val()) {
          message = "Please enter " + input.attr("max") + " or less";
        }
        else if (typeof input.attr("min") !== 'undefined' && input.attr("min") > input.val()) {
          message = "Please enter " + input.attr("min") + " or more";
        }
      }
      
      /** use setCustomValidity method built into browser to update the message **/
      if ( message !== null ){
        el.setCustomValidity(message);
      }
    }
  });

#Legacy Browser Support Currently if the browser does not support element.checkValidity Scrupulous will silently fail. You should be using solid server side validation as a backup. It may be possible to use it in conjunction with a HTML5 form validation polyfill. Let us know if you have any luck.

##Modernizr.load Example Scrupulous may also be loaded with Modernizr.load as well.


  Modernizr.load({
      test: Modernizr.input.required,
      yep: 'js/scrupulous.js',
      complete: function() {
        $('#my-form').scrupulous();
      }
    });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].