Skip to content

Commit

Permalink
update to v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Octagon-simon committed May 23, 2022
1 parent b262506 commit 0698265
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# octaValidate V1.1.0
# octaValidate V1.1.1

<img align="center" src="https://octagon-simon.github.io/octaValidate/img/ov-success.png" width="100px">

Expand Down Expand Up @@ -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)")
}
Expand Down Expand Up @@ -267,18 +268,16 @@ 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

[Read the article on Medium](https://blog.bitsrc.io/client-side-form-validation-using-octavalidate-javascript-b150f2d14e99)

## 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

Expand Down
17 changes: 10 additions & 7 deletions src/validate.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 0698265

Please sign in to comment.