GithubHelp home page GithubHelp logo

ritsu.js's Introduction

ritsu.js

HTML form validation and utilities. Check out the latest release.

What is this?

A dumb and simple little HTML form validator. It relies heavily on HTML classes to make it very simple to validate input fields. Also comes with some spiffy utilities.

Why?

This all started as a need to easily validate my own forms fields without being able to use someone else's validation plug-in. The result was a mini validation library that has worked pretty well for my projects.

Perhaps someone else will find this useful.

Dependencies?

No dependencies! Uses pure javascript. Make sure to check out the browser compatibility table.

Documentation

Read the wiki. Also there is probably tons of spelling mistakes and stuff. Please let me know if you find any.

Anything else?

I'm wondering if I should switch this from a singleton approach to something else.

ritsu.js's People

Contributors

nypd avatar

Stargazers

Justin Frey avatar Tyler Crawford avatar

Watchers

James Cloos avatar  avatar

ritsu.js's Issues

Allow to get error message for particular input(s)

Or maybe some sort of functionality to display error messages somewhere else.

  • initialize() should take a errorCallback function
  • validate() should take a temp errorCallback function
  • showErrorMessages() should take a temp errorCallback function maybe?
  • getErrorMessage()
  • getErrorMessages()
  • getErrorMessagesAsMap()

v1.2.0 Changelog

Changes

  • #66 Added ability to pass in a query string selector to all methods rather than just a jQuery object or element node
  • #55
    • Added functionality to reset form inputs to their initial values from when the storeInitialValues() was ran.
    • Added functionality to retrieve the initial value of a single input element
  • #61
    • initialize() now takes a messageCallback function
    • validate() now takes a messageCallback function
    • showErrorMessages() now takes a messageCallback function
    • new method to get an error message for a particular input
    • new method to get error messages for several inputs
    • new method to get error messages for several inputs as a "map"
  • #71 Added version variable to the ritsu library

Fixes

  • #69 When not using bootstrap styles, ritsu now removes previous error labels rather than leaving them there
  • #75 (Severe) Two different copies of the rules object were present in ritsu leading to some unexpected behaviors

Wiki

  • Add how one can use query selectors now when calling methods
  • Add entry on how initial values are stored in the storeInitialValues()
  • Add getInitialFormValue() method entry
  • Add resetIntialFormValues() method entry
  • Add entry on new messageCallback property in initialize()
  • Add how one can reset all options to default in initialize() when calling it with a empty object
  • Add new signature for the initialize() method to take a messageCallback function
  • Add new signature for the validate() method to take a messageCallback function
  • Add new signature for the showErrorMessages() method to take a messageCallback function
  • Add new method entry getErrorMessage()
  • Add new method entry getErrorMessages()
  • Add new method entry getErrorMessagesAsMap()

v1.1.1 Changelog

Changes

  • If bootstrap is used and a input is validated that is not a in a form group, the has-error class will be put on the input instead of throwing a null errror. #56
  • Using storeInitialFormValues() on file inputs will no longer throw an error. #57

jQuery Datepicker does not validate hand entered dates

When manually typing a date, the datepicker does not check for any constraints like min date or max date. It only makes sure that the input is in the correct format using contrainInput.

Perhaps ritsu should try to read the options and validate it for them, or maybe see if it can re-set the date and have it rejected by datepicker.

Consider a alpha-all rule

Or perhaps if the user has alpha or numeric validate to make sure something is filled out at least.

If an input is not in a form-group and it valid, exception gets thrown

  var errorElement = useBootstrap3Stlying ? _getClosestParentByClass(element, 'form-group') : element;

  var isInvalid = element.getAttribute('data-invalid') === 'true';

  if (isInvalid)
    errorElement.classList.add('has-error');
  else
    errorElement.classList.remove('has-error');

errorElement will be null therefore not be able read the property classList of null.

So basically if it can not find the form-group, use the element itself

v1.1.0 change log

Changes

  • Ritsu no longer removes .error-label elements from the parent `td'
  • Ability to pass in elements or jQuery selectors to all ritsu methods that take in a selector

Wiki

  • Add browser compatibility chart or something
  • Methods now take either an html element or jQuery selector

file.lastModifiedDate is deprecated

We are currently using file.lastModified, but I cant find documentation related to this property. This fileModifed is also a little wonky when trying to compare equality.

We should remove it for the next version

v1.1.2 Changelog

Changes

  • #60 ritsu no longer validates hidden uinput

Fixes

  • #62 Fixed issue where file inputs were being mark as invalid when they contained data-simple-file-hash

v1.0.0 Wiki updates

  • alpha-only now takes in an optional data-no-space attribute to disallow spaced
  • alpha-numeric now accepts spaces by default. It also takes in an optional data-no-space attribute to disallow spaces
  • Removed the optional css class in favor of using a required attribute

``

  • Add browser compatibility chart or something
  • Ability to pass in elements or jQuery selectors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.