1.2.1 • Published 7 years ago

simple-validation-form v1.2.1

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

Simple Validation Form

Install

npm install --save simple-validation-form

Configuration

PropertyTypeInfoDefault
inputsString|NodeContaints inputs which you want to validateform > input:not(type="submit")
showErrorMessagesBooleanTo show or not error messagestrue
submitBtnString|NodeForm Button , which is disabled until the ALL inputs value is inccorectform > inputtype="submit"
errorsClassString|NodeError class which you can style how that you want , default is`t styled |errors
useClassesBooleanTo use or not classes for inputstrue
countryCodeNumberYour country telephone number code (for validation)995
telLengthNumberTelephone number length (for validation)9
nameMinLengthNumberName input MIN length (for validation)4
nameMaxLengthNumberName input MAX length (for validation)12
successColorStringBorder Color if validate is correct#66bb6a
errorColorStringBorder Color if validate is inccorect#d32f2f
successClassString|NodeThe class for input if it correct validate , default not styledcorrect
errorClassString|NodeThe class for input if it inccorect validate , default not stylederror

Methods

Important

Use name attribute for inputs , otherwise validaton can`t work !

For now , you can use this names:

  • name
  • email
  • telephone
  • password

Static Html

<!-- Example -->

......
 <form>
   <!-- INPUT MUST HAVE NAME ATTRIBUTE FOR VALIDATE , WITHOUT IT 
        DOES`T WORK!!! AND NAME VALUE MUST BE EQUAL TO TYPE VALUE
        FOR CORRECT VALIDATE
        -->
   <input type="text"  name="name"  placeholder="Some name..." class="test">
   <input type="email" name="email" placeholder="example@exapmle">
   <input type="cite"  name="cite"  placeholder="https://example.exm">
   .....
  
    <input type="submit" value="Submit">
</form>

......
 <script src="/node_modules/simple-validation-form/simple_validation.js"></script>
 <script>
   // Add Custom Pattern 
   Validator.addPattern('cite' , /^https?:\/\// , true)
      // Or
   Validator.addPattern('cite' , /^https?:\/\// , 'Something goes wrong')
      // Or
   Validator.addPattern({
      cite: /^https?:\/\//
   } , true )
 
 
    // Set Validate 
    Validator.set({
      showErrorMessages:false,
      countryCode:1
      //.........///
    });
    
   // Start Validate 
   Validator.validate();
 </script>

In NodeJs

import 'simple-validation-form'

   Validator.validate();