From 069826552c84e6f6b1eaf55e56d25b41d201662c Mon Sep 17 00:00:00 2001 From: Octagon Date: Mon, 23 May 2022 18:01:40 +0100 Subject: [PATCH] update to v1.1.1 --- README.md | 11 +++++------ src/validate.js | 17 ++++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6af0bd3..67182a9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# octaValidate V1.1.0 +# octaValidate V1.1.1 @@ -227,10 +227,11 @@ To define a callback, invoke this method and pass in your function as an argumen ```javascript //create new instance of the function let formVal = new octaValidate('form_register'); - +//success callback let successCB = function(){ alert("No validation errors"); } +//error callback let errorCB = function(){ alert(formVal.status()+" validation error(s)") } @@ -267,9 +268,8 @@ let formVal = new octaValidate('form_register'); - customRule(RULE_TITLE, REG_EXP, ERROR_TEXT): Invoke this method to define your custom validation rule. - moreCustomRules(RULES): Invoke this method to define more custom validation rules. - version(): Invoke this method to retrieve version info. -- validateCallBack(success_callback, error_callback): Invoke this method, providing your success callback or error callback as arguments. +- validateCallBack(success_callback, error_callback): Invoke this method, providing your success callback or error callback as arguments. The success callback will execute when there are no validation errors and the error callback will execute when there are validation errors -The success callback will execute when there are no validation errors and the error callback will execute when there are validation errors ## READ THE ARTICLE @@ -277,8 +277,7 @@ The success callback will execute when there are no validation errors and the er ## DEMO -- Download **octaValidate** and import it to your project. -- Open **[demo.html](https://octagon-simon.github.io/octaValidate/demo.html)** on a browser, then submit the form. +- Open **[demo.html](https://octagon-simon.github.io/octaValidate/demo.html)** (also included in the folder) and submit the form. ## SCREENSHOTS diff --git a/src/validate.js b/src/validate.js index bb284e5..c63a883 100644 --- a/src/validate.js +++ b/src/validate.js @@ -1,7 +1,7 @@ /** - * OctaValidate main JS V1.1.0 + * OctaValidate main JS V1.1.1 * author: Simon Ugorji - * Last Edit : 21st May 2022 + * Last Edit : 23rd May 2022 */ (function(){ //global Styling @@ -402,12 +402,14 @@ function octaValidate(form_ID, userConfig){ if(validate !== null || validateAttr !== null){ //loop through all form elements with an ID attached to it - let formInputs = document.querySelectorAll(`#${form_id} input[id], textarea[id]`); + let formInputs = document.querySelectorAll(`#${form_id} [octavalidate], [length], [maxlength], [minlength], [equalto]`); formInputs.forEach(input => { - //errors is unique to the input id - let formInputId = input.id; - /* strict mode */ - //check if strict mode is enabled + //check if id exists within the element + if(input.id !== ""){ + //errors is unique to the input id + let formInputId = input.id; + /* strict mode */ + //check if strict mode is enabled if(config.strictMode === true){ /* always reset the vcounters */ nextValidation = continueValidation = 0; @@ -984,6 +986,7 @@ function octaValidate(form_ID, userConfig){ }else{ nextValidation++; }//end of if id exists + }//end of check if id is provided }); //end of foreach loop }//end of checkif validations exist if(errors === 0){