GithubHelp home page GithubHelp logo

matej116 / live-form-validation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from contributte/live-form-validation

0.0 3.0 0.0 115 KB

:no_entry: Nice client-side live form validation for Nette Forms.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

live-form-validation's Introduction

Live Form Validation

⛔ Nice client-side live form validation for Nette Forms 2.4.


Build Status Licence Downloads total Latest stable

Discussion / Help

Join the chat

Install

NPM

npm install --save live-form-validation

Manually

All you need is to link live-form-validation.js file from to your HTML document. That's it!

The script already contains the netteForms.js file, so don't use it again and remove it from your HTML document.

Rawgit

  • Dev: https://rawgit.com/contributte/live-form-validation/master/live-form-validation.js
  • Stable: https://cdn.rawgit.com/contributte/live-form-validation/v1.8.1/live-form-validation.js

Versions

State Version Branch
development ^1.9.0 master
stable ^1.8.1 master

Usage

Script by default works nicely with Twitter Bootstrap 3, but you can customize the options to fit your exact needs.

Options

You can change default options by calling LiveForm.setOptions({ ... }); after including the script. Give only options that you want to change. For example:

<script src="/js/live-form-validation.js"></script> 
<script>
	LiveForm.setOptions({
		messageErrorPrefix: 'Error: ',
		wait: 500
	});
</script> 

Alternatively, if you want to set options before the script is loaded, create LiveFormOptions = { ... }; with options that you want to change. For example:

<script>
	LiveFormOptions = {
		messageErrorPrefix: 'Error: ',
		wait: 500
	};
</script> 
<script src="/js/live-form-validation.js"></script> 

Available options

Option Description
showMessageClassOnParent CSS class of control's parent where error/valid class should be added; or "false" to use control directly
messageParentClass CSS class of control's parent where error/valid message should be added (fallback to direct parent if not found); or "false" to use control's direct parent
controlErrorClass CSS class for an invalid control
controlValidClass CSS class for a valid control
messageErrorClass CSS class for an error message
enableHiddenMessageClass control with this CSS class will show error/valid message even when control itself is hidden (useful for controls which are hidden and wrapped into special component)
disableLiveValidationClass control with this CSS class will have disabled live validation
disableShowValidClass control with this CSS class will not show valid message
messageTag tag that will hold the error/valid message
messageIdPostfix message element id = control id + this postfix
messageErrorPrefix show this html before error message itself
showAllErrors show all errors when submitting form; or use "false" to show only first error
showValid show message when valid
wait delay in ms before validating on keyup/keydown; or use "false" to disable it
focusScreenOffsetY vertical screen offset in px to scroll after focusing element with error (useful when using fixed navbar menu which may otherwise obscure the element in focus); or use "false" for default behavior

Special features

  • Form on load validation - Adding class validate-on-load to form element will execute its validation immediately after page is loaded.

Advanced

You can edit/replace methods LiveForm.addError (shows error message), LiveForm.removeError (hides error message), LiveForm.showValid (show message if input is correctly filled), LiveForm.setupHandlers (sets handlers up for inputs, like focus, blur, onkeyup). These methods can be altered to support some JS framework, ie. jQuery.

Maintainers


Milan Felix Šulc

Authors

This script is based on work of Robert Pösel, zakrava, Radek Ježdík, MartyIX and David Grudl.

Thank you all!


Robert Pösel

Zakrava

Radek Ježdík

Martin Vseticka

David Grudl

Thank you for testing, reporting and contributing.

live-form-validation's People

Contributors

f3l1x avatar janiczek avatar jelen07 avatar pavelplzak avatar redhead avatar robyer avatar

Watchers

 avatar  avatar  avatar

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.