Modal Box Input
A modal box for input data with data validation and customizable style [BUGFIX RESOLVED (base path css bug)]
Getting Started
npm install modal-box-input --save
Simple Use
get boxclass from module
var boxClass = ModalBoxInput;var Box = "title" "message" "input 1 name" "input 2 name" ... "input n name" "ok button text" "reset button text";Box;
and now
Box;
Styling
for styling Box class automatically insert a tag
if your path is different you can use
currentCssFile = "../node_modules/Modal-Box-Input/dist/ModalBoxInput.css";public //currentCssFile ="../node_modules/Modal-Box-Input/dist/[filename]";public //currentCssFile = "../[filepath]/ModalBoxInput.css";public //currentCssFile = "[filebase]node_modules/Modal-Box-Input/dist/ModalBoxInput.css";
to set a different location for css stylesheet or copy ModalBoxInput.css in your index folder and set css file so:
public //currentCssFile = [filepath];
Validation
it's also possible validate the input applying validation rule
first get validationRule class
var VRClass = validationRule;//use// var rule = new VRClass("input name", function(value_valueof_input){//code that return a boolean}, "error message");var username0 = "username" {return val!=null && val!=undefined && vallength>0?true:false;} "field can't be empty";var username1 = "username" {return vallength>3?true:false;} "field length must be > 3";var password0 = "password" {return val!=null && val!=undefined && vallength>0?true:false;} "field can't be empty";var password1 = "password" {return vallength>3?true:false;} "field length must be > 3";
and now (before open) set validation rule
Box;Box;
insert rules in a sequence that run by more generic to more specific rule
Validation Update
by this release are available default validation functions obtained by DefaultRules class; first get an istance of DefaultRules class:
var DRClass = DefaultRules;var DR = ;
DR has this Default Functions
DRNOT_EMPY //no parametersDREQUAL//single number parameter DR//single number parameter evaluate (input val) >= minDR//single number parameter evaluate (input val) <= maxDR//two number parameter evaluate (input val)>= min && (input val)<= max
Here a complete example:
var boxClass = ModalBoxInput;var DRClass = DefaultRules;var ValRuleClass = validationRule; var Box = "New Account" "Complete your subscription" "Name" "Surname" "Username" "Password" "Email";var DR = ;var name0 = "Name" DRNOT_EMPTY "field can't be empty";var name1 = "Name" DR "field length must be >= 3 && <= 20"; var surname0 = "Surname" DRNOT_EMPTY "field can't be empty";var surname1 = "Surname" DR "field length must be >= 3 && <= 20"; var username0 = "Username" DRNOT_EMPTY "field can't be empty";var username1 = "Username" DR "field length must be >= 3 && <= 20"; var password0 = "Password" DRNOT_EMPTY "field can't be empty";var password1 = "Password" DR "field length must be >= 8 && <= 20"; var email0 = "Email" DRNOT_EMPTY "field can't be empty";var email1 = "Email" DR "field length must be >= 4 && <= 30"; { ifval!=-1 && val!=-1return true; return false;}var email2 = "Email" SimplyEmailCheck "field isn't a valid Email"; Box; Box; Box;
Documentation
Built With
Typescript
Browserify
Gulp
Stylus
Author
License
This project is licensed under the MIT License