@@ -62,11 +62,11 @@ function jsValidator() {
6262 // Update default response "class".
6363 if ( 'undefined' === typeof option . errorClass ) option . errorClass = 'js-error-cop' ;
6464 // Update "jsSettings" to global object.
65- this . jsSettings = jsSettings . init ( option ) ;
65+ this . jsSettings = new jsSettings ( ) . init ( option ) ;
6666 // Update "jsForm" to global object.
67- this . jsForm = jsForm . init ( option ) ;
67+ this . jsForm = new jsForm ( ) . init ( option ) ;
6868 // Initiate form error setup.
69- this . jsFormError = jsFormError . init ( ) ;
69+ this . jsFormError = new jsFormError ( ) . init ( ) ;
7070 // Update Force Field status.
7171 this . forceFilter = option . forceFilter ;
7272 // To check the form elements.
@@ -101,11 +101,11 @@ function jsValidator() {
101101 // Updating the filter flag to global.
102102 this . onlyFilter = option . onlyFilter ;
103103 // Update "jsSettings" to global object.
104- this . jsSettings = jsSettings . init ( option ) ;
104+ this . jsSettings = new jsSettings ( ) . init ( option ) ;
105105 // Update "jsForm" to global object.
106- this . jsForm = jsForm . init ( option ) ;
106+ this . jsForm = new jsForm ( ) . init ( option ) ;
107107 // Initiate form error setup.
108- this . jsFormError = jsFormError . init ( ) ;
108+ this . jsFormError = new jsFormError ( ) . init ( ) ;
109109 } ;
110110 /*
111111 * To checking all elements from registered form.
@@ -168,7 +168,7 @@ function jsValidator() {
168168 // If not only filter, then start validations.
169169 if ( false === this . onlyFilter || typeof ( this . onlyFilter ) === 'undefined' ) {
170170 // Initiate validations and update to log.
171- log = jsRuleSets . checkValidation ( activeElem , log ) ;
171+ log = new jsRuleSets ( ) . checkValidation ( activeElem , log ) ;
172172 }
173173 }
174174 }
@@ -180,17 +180,17 @@ function jsValidator() {
180180 */
181181 this . applyFilters = function ( activeElem ) {
182182 // Apply filter for Number elements.
183- if ( activeElem . type == 'number' ) jsFilter . number ( activeElem ) ;
183+ if ( activeElem . type == 'number' ) new jsFilter ( ) . number ( activeElem ) ;
184184 // Apply filter for Email elements.
185- if ( activeElem . type == 'email' ) jsFilter . email ( activeElem ) ;
185+ if ( activeElem . type == 'email' ) new jsFilter ( ) . email ( activeElem ) ;
186186 // Apply filter for Numeric elements.
187187 // if (activeElem.min || activeElem.max || activeElem.minLength || activeElem.maxLength) jsFilter.limit(activeElem);
188188 // Apply filter File elements.
189- if ( activeElem . type == 'file' ) jsFilter . file ( activeElem ) ;
189+ if ( activeElem . type == 'file' ) new jsFilter ( ) . file ( activeElem ) ;
190190 // Apply filter with string, alphaNumeric and pregMatch.
191- if ( activeElem . getAttribute ( 'data-allow' ) ) jsFilter . string ( activeElem ) ;
191+ if ( activeElem . getAttribute ( 'data-allow' ) ) new jsFilter ( ) . string ( activeElem ) ;
192192 // Apply filter with pattern.
193- if ( activeElem . getAttribute ( 'pattern' ) ) jsFilter . pattern ( activeElem ) ;
193+ if ( activeElem . getAttribute ( 'pattern' ) ) new jsFilter ( ) . pattern ( activeElem ) ;
194194 } ;
195195 /*
196196 * To make it active to listen changes of those error fields.
@@ -205,9 +205,9 @@ function jsValidator() {
205205 // jsLogger.out('Quick', event);
206206 var log = [ ] ;
207207 var target = event . target ;
208- log = jsRuleSets . checkValidation ( target , log ) ;
208+ log = new jsRuleSets ( ) . checkValidation ( target , log ) ;
209209 // jsLogger.out('Quick Out', log);
210- validationResponse . process ( log ) ;
210+ new validationResponse ( ) . process ( log ) ;
211211 } ;
212212 /*
213213 * Single step instance validator for Ajax form submissions.
@@ -224,7 +224,7 @@ function jsFilter() {
224224 this . checkStatus = function ( elem ) {
225225 var status ;
226226 status = true ;
227- if ( false === jsValidator . forceFilter ) {
227+ if ( false === new jsValidator ( ) . forceFilter ) {
228228 status = false ;
229229 if ( true === elem . required ) {
230230 status = true ;
@@ -336,7 +336,7 @@ function jsFilter() {
336336 // To check is this action is from "windows" action or not.
337337 if ( true === helper . isWindowAction ( event ) ) return true ;
338338 // Managing the Pattern.
339- var status = pattern . validate ( event , 'a-zA-Z0-9' ) ;
339+ var status = new pattern ( ) . validate ( event , 'a-zA-Z0-9' ) ;
340340 // Return status of the Action.
341341 if ( false === status ) event . preventDefault ( ) ;
342342 } ;
@@ -354,7 +354,7 @@ function jsFilter() {
354354
355355 if ( true === helper . isWindowAction ( event ) ) return true ;
356356 // Managing the Pattern.
357- var status = pattern . validate ( event , 'a-zA-Z0-9' ) ;
357+ var status = new pattern ( ) . validate ( event , 'a-zA-Z0-9' ) ;
358358 // Return status of the Action.
359359 if ( false === status ) event . preventDefault ( ) ;
360360 } ;
@@ -365,7 +365,7 @@ function jsFilter() {
365365 // To check is this action is from "windows" action or not.
366366 if ( true === helper . isWindowAction ( event ) ) return true ;
367367 // Managing the Pattern.
368- var status = pattern . validate ( event , 'a-zA-Z0-4' ) ;
368+ var status = new pattern ( ) . validate ( event , 'a-zA-Z0-4' ) ;
369369 // Return status of the Action.
370370 if ( false === status ) event . preventDefault ( ) ;
371371 } ;
@@ -385,6 +385,7 @@ function jsFilter() {
385385 return true ;
386386 } ;
387387}
388+
388389/**
389390 * To Update overall JsValidator Settings.
390391 */
@@ -481,12 +482,13 @@ function jsForm() {
481482 this . required = function ( ) {
482483 // var jsField = new jsField().init(this.options);
483484 var forceFilter = this . forceFilter ;
485+ var jsField_obj = new jsField ( ) ;
484486 // Filter all required "input" elements.
485- this . input = jsField . required ( this . input , forceFilter ) ;
487+ this . input = jsField_obj . required ( this . input , forceFilter ) ;
486488 // Filter all required "select" elements.
487- this . select = jsField . required ( this . select , forceFilter ) ;
489+ this . select = jsField_obj . required ( this . select , forceFilter ) ;
488490 // Filter all required "textArea" elements.
489- this . textArea = jsField . required ( this . textArea , forceFilter ) ;
491+ this . textArea = jsField_obj . required ( this . textArea , forceFilter ) ;
490492 } ;
491493 /*
492494 * General Log.
@@ -530,8 +532,9 @@ function jsRuleSets() {
530532 this . checkValidation = function ( activeElem , log ) {
531533 //jsLogger.out('Active Elem', activeElem);
532534 var validElem = true ;
535+ var jsRuleSets_obj = new jsRuleSets ( ) ;
533536 // To Generally checks, the field is empty or not.
534- if ( ! jsRuleSets . isSet ( activeElem ) ) {
537+ if ( ! jsRuleSets_obj . isSet ( activeElem ) ) {
535538 log . push ( {
536539 'el' : activeElem ,
537540 'type' : 'required' ,
@@ -542,8 +545,8 @@ function jsRuleSets() {
542545
543546 // To Check the Value is less than minimum or not.
544547 if ( activeElem . min ) {
545- if ( jsRuleSets . isSet ( activeElem ) ) {
546- if ( ! jsRuleSets . min ( activeElem ) ) {
548+ if ( jsRuleSets_obj . isSet ( activeElem ) ) {
549+ if ( ! jsRuleSets_obj . min ( activeElem ) ) {
547550 log . push ( {
548551 'el' : activeElem ,
549552 'type' : 'min' ,
@@ -557,8 +560,8 @@ function jsRuleSets() {
557560
558561 // To Check the Value is grater than max or not.
559562 if ( activeElem . max ) {
560- if ( jsRuleSets . isSet ( activeElem ) ) {
561- if ( ! jsRuleSets . max ( activeElem ) ) {
563+ if ( jsRuleSets_obj . isSet ( activeElem ) ) {
564+ if ( ! jsRuleSets_obj . max ( activeElem ) ) {
562565 log . push ( {
563566 'el' : activeElem ,
564567 'type' : 'max' ,
@@ -572,8 +575,8 @@ function jsRuleSets() {
572575
573576 // To Check the Entered E-mail is Valid or Not.
574577 if ( activeElem . type == 'email' ) {
575- if ( jsRuleSets . isSet ( activeElem ) ) {
576- if ( ! jsRuleSets . email ( activeElem ) ) {
578+ if ( jsRuleSets_obj . isSet ( activeElem ) ) {
579+ if ( ! jsRuleSets_obj . email ( activeElem ) ) {
577580 log . push ( {
578581 'el' : activeElem ,
579582 'type' : 'email' ,
@@ -588,8 +591,8 @@ function jsRuleSets() {
588591 // To Compare the Password is Same or Not with Re-Password.
589592 // TODO: Implement Simplified Comparison.
590593 if ( activeElem . type == 'password' ) {
591- if ( jsRuleSets . isSet ( activeElem ) ) {
592- if ( ! jsRuleSets . compare ( activeElem ) ) {
594+ if ( jsRuleSets_obj . isSet ( activeElem ) ) {
595+ if ( ! jsRuleSets_obj . compare ( activeElem ) ) {
593596 log . push ( {
594597 'el' : activeElem ,
595598 'type' : 'password' ,
@@ -769,37 +772,38 @@ function jsFormError() {
769772/**
770773 * For manage overall logging with validator.
771774 */
772- function jsLogger ( ) {
773- this . status = function ( ) {
774- return jsValidator . option . log
775- } ;
775+ var jsLogger = {
776+ status : function ( ) {
777+ // return jsValidator.option.log;
778+ return '[]' ;
779+ } ,
776780 /*
777781 * Simple log with "heading" and "message".
778782 */
779- this . out = function ( heading , message ) {
783+ out : function ( heading , message ) {
780784
781785 if ( true !== this . status ( ) ) return false ;
782786 console . log ( '======' + heading + '======' ) ;
783787 console . log ( message ) ;
784788 console . log ( '------------------------' ) ;
785- } ;
789+ } ,
786790 /*
787791 * For bulk data logging.
788792 */
789- this . bulk = function ( data ) {
793+ bulk : function ( data ) {
790794 if ( true !== this . status ( ) ) return false ;
791795 console . log ( data ) ;
792- } ;
796+ } ,
793797 /*
794798 * For log data with table.
795799 */
796- this . table = function ( data ) {
800+ table : function ( data ) {
797801 if ( true !== this . status ( ) ) return false ;
798802 console . table ( data ) ;
799- } ;
800- }
803+ }
804+ } ;
801805/**
802- * General Helping methods.
806+ * General Helping methods.jsField_obj
803807 */
804808var helper = {
805809 /*
@@ -827,7 +831,7 @@ var helper = {
827831 */
828832 scrollToError : function ( ) {
829833 var dummy_id = '__header_error_target_temp' ;
830- var active_class = validationResponse . getClass ( ) ;
834+ var active_class = new validationResponse ( ) . getClass ( ) ;
831835 if ( 0 === document . getElementsByClassName ( active_class ) . length ) return false ;
832836 // Getting current ID of the element.
833837 var active_id = document . getElementsByClassName ( active_class ) [ 0 ] . id ;
0 commit comments