Skip to content

Commit d89576d

Browse files
Update README.md
1 parent ef53fc2 commit d89576d

1 file changed

Lines changed: 39 additions & 22 deletions

File tree

README.md

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@
1818

1919
**Steps to Integrate to Form :**
2020

21+
```html
2122
<script src="./../src/js/formValidator.js"></script>
23+
```
2224

2325
Then Integrate your form with Validator.
2426

2527
28+
```javascript
29+
var myform = new jsValidator().init({
30+
form: 'form2submit',
31+
forceFilter: true
32+
});
2633
```
27-
var data = {
28-
form: 'new_ticket_form', // Required.
29-
warning_color: 'aa0000', // Optional.
30-
new_class: 'test' // Optional.
31-
};
32-
33-
// Validation Will Init Here.
34-
validate(data);
34+
#### To check validation
35+
36+
```javascript
37+
myform.check() // True | False
38+
```
39+
40+
#### To apply on dynamic elements
41+
42+
```javascript
43+
myform.update() // It will update the DOM.```
3544
```
3645
3746
@@ -44,16 +53,16 @@ It has automated listener to eliminating unnecessary changes on form.
4453
1. Validation take place between tags, so need to specify the **ID**
4554
of the Form or any other tags.
4655

47-
```
56+
```html
4857
<form id="newUser"> </form> // Preferred
4958

5059
<div id=newUser> </div> // Not-Preferred [but it supports]
51-
```
60+
```
5261
5362
2. Input Fields should specify the type of validation.
5463

5564
#### For General Input Validation
56-
65+
```html
5766
// For Simple Require.
5867
<input type="text" required name="name">
5968

@@ -68,34 +77,42 @@ It has automated listener to eliminating unnecessary changes on form.
6877

6978
// For Password Match Validation.
7079
<input type="password" required match="field_name" name="password">
80+
```
7181

7282
#### For Select Validation
73-
74-
//For Simple Required
75-
<select class="" required>
76-
<option value="-"></option> // Value '-' is used to represent empty.
77-
<option value="...">...</option>
78-
<option value="...">...</option>
79-
<option value="...">...</option>
80-
</select>
81-
83+
84+
```Javascript
85+
//For Simple Required
86+
<select class="" required>
87+
<option value=""></option>
88+
<option value="...">...</option>
89+
<option value="...">...</option>
90+
<option value="...">...</option>
91+
</select>
92+
```
93+
8294
#### For Textarea Validation
95+
```Html
8396

8497
// For Simple Required
8598
<textarea required>.....</textarea>
86-
99+
```
87100

88101
3. Every Input Fields should have a Label with **FOR** attributes.
89102

103+
```Html
90104
<label for="uname">Name :</label>
91105
<input type="text" name="uname" required>
106+
```
92107

93108
4. In form use "**novalidate**" to avoid browser interuptions.
94-
109+
110+
````Html
95111
<form method="POST/GET.." action="PATH TO HANDLE" ... novalidate>
96112
...
97113
...
98114
</form>
115+
````
99116

100117

101118
It Will listen the **Submit** button event **Automatically**.

0 commit comments

Comments
 (0)