Skip to content

Commit

Permalink
patch for v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Octagon-simon committed Oct 9, 2022
1 parent 6265972 commit 7a68416
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Octavalidate - JS V1.2.2
# Octavalidate - JS V1.2.3

This JavaScript library helps to validate your frontend (HTML) forms using validation rules, sophisticated regular expressions and form input attributes.

Expand All @@ -25,7 +25,7 @@ Visit the [DOCUMENTATION](https://octagon-simon.github.io/projects/octavalidate/
### CDN
Place this script before the <code>&lt;/head&gt;</code> tag.
```html
<script src="https://unpkg.com/[email protected].2/native/validate.js"></script>
<script src="https://unpkg.com/[email protected].3/native/validate.js"></script>
```

### NPM
Expand Down
11 changes: 7 additions & 4 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
</style>

<!-- CDN
<script src="https://unpkg.com/[email protected].2/native/validate.js"></script>
<script src="https://unpkg.com/[email protected].3/native/validate.js"></script>
-->

<script src="src/validate.js"></script>
Expand Down Expand Up @@ -567,13 +567,16 @@ <h3 class="text-white mb-20">CONNECT WITH ME</h3>
data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#ffffff"
data-coffee-color="#FFDD00"></script>
</div>
<p class="text-gray mt-20">Octavalidate @ 1.2.2 🚀 Since January 2022 </p>
<p class="text-gray mt-20">Octavalidate @ 1.2.3 🚀 Since January 2022 </p>
</footer>

</html>
<script>
//create instance of class
let myForm = new octaValidate('form_demo');
//create instance of class null, NaN,undefined,admin,empty
let myForm = new octaValidate('form_demo', {
strictMode : true,
strictWords : ["null", "empty", "undefined", "NaN"]
});
//add custom rule
myForm.customRule("PASS", /^12345+$/, "Please enter 12345");
//define callback
Expand Down
Binary file modified img/strict-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions src/validate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* OctaValidate main JS V1.2.2
* OctaValidate main JS V1.2.3
* author: Simon Ugorji
* Last Edit : 2nd October 2022
* Last Edit : 9th October 2022
*/

(function () {
Expand Down Expand Up @@ -54,10 +54,10 @@ function octaValidate(form_ID, userConfig) {
const config = {
successBorder: true,
strictMode: false,
strictWords: ["null", "NaN", "undefined"]
strictWords: ["undefined"]
};
//version number
const versionNumber = "1.2.2";
const versionNumber = "1.2.3";

////---------------

Expand Down Expand Up @@ -206,7 +206,11 @@ function octaValidate(form_ID, userConfig) {
(userConfig.strictMode == true || userConfig.strictMode == false) ? config.strictMode = userConfig.strictMode : null;
}
if (userConfig.strictWords !== undefined && userConfig.strictMode !== undefined) {
(userConfig.strictMode == true && userConfig.strictWords.length !== 0) ? config.strictWords.push(...userConfig.strictWords) : null;
if(userConfig.strictMode && userConfig.strictWords.length !== 0) {
//merge both arrays but remove duplicates
config.strictWords = [... new Set([... config.strictWords, ... userConfig.strictWords])]
//admin, undefined, null, NaN
}
}
}

Expand Down Expand Up @@ -673,7 +677,7 @@ function octaValidate(form_ID, userConfig) {

if ((elem.value !== "") && (checkStrictWords(elem.value).length !== 0) && elem.type !== "file" && elem.type !== "checkbox" && elem.type !== "radio") {
errors[formInputId]++;
validationText = (elem.getAttribute('ov-strict:msg')) ? elem.getAttribute('ov-strict:msg').toString() : `Please remove or replace ${checkStrictWords(elem.value)}`;
validationText = (elem.getAttribute('ov-strict:msg')) ? elem.getAttribute('ov-strict:msg').toString() : `Please remove or replace '${checkStrictWords(elem.value).join(', ')}'`;
ovRemoveSuccess(index);
ovNewError(index, validationText);
if (elem.addEventListener) {
Expand Down

0 comments on commit 7a68416

Please sign in to comment.