Skip to content

Commit 6d3cf8f

Browse files
authored
Merge pull request #10 from skttl/docs
Add docs changes
2 parents f13bfdd + 017c8f2 commit 6d3cf8f

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

README.MD

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ v.bootstrap();
4646

4747
```js
4848
require('core-js');
49-
const aspnetValidation = require('aspnet-validation');
49+
const aspnetValidation = require('aspnet-client-validation');
5050

5151
let v = new aspnetValidation.ValidationService();
5252
v.bootstrap();
@@ -56,7 +56,7 @@ v.bootstrap();
5656

5757
```ts
5858
import 'ts-polyfill';
59-
import { ValidationService } from 'aspnet-validation';
59+
import { ValidationService } from 'aspnet-client-validation';
6060

6161
let v = new ValidationService();
6262
v.bootstrap();
@@ -126,7 +126,7 @@ public class ClassicMovieAttribute : ValidationAttribute, IClientModelValidator
126126
### Client Code
127127

128128
```ts
129-
import { ValidationService } from 'aspnet-validation';
129+
import { ValidationService } from 'aspnet-client-validation';
130130
let v = new ValidationService();
131131

132132
v.addProvider('classicmovie', (value, element, params) => {
@@ -170,8 +170,52 @@ v.addProvider('io', (value, element, params) => {
170170
## Subscribing to Client Form Validation Event
171171

172172
```ts
173-
cost form = document.getElementById('form');
173+
const form = document.getElementById('form');
174174
form.addEventListener('validation', function (e) {
175175
/* Check if form is valid here. */
176176
});
177177
```
178+
179+
## Programatically validate a form
180+
181+
```ts
182+
v.validateForm(document.getElementById('form'));
183+
```
184+
185+
## Checking form validity
186+
187+
```ts
188+
v.isValid(document.getElementById('form'))
189+
```
190+
191+
By default it will try to validate the form, before returning whether the form is valid. This can be disabled by setting the `prevalidate` parameter like so:
192+
193+
```ts
194+
v.isValid(document.getElementById('form'), false)
195+
```
196+
197+
You can also supply a callback function to be run after the check.
198+
199+
```ts
200+
v.isValid(document.getElementById('form'), true, myCallbackFn)
201+
```
202+
203+
## Checking field validity
204+
205+
Similar to checking a forms validity, you can check individual fields too.
206+
207+
```ts
208+
v.isFieldValid(document.getElementById('field'))
209+
```
210+
211+
By default it will try to validate the form surrounding the field, before returning whether the field is valid. This can be disabled by setting the `prevalidate` parameter like so:
212+
213+
```ts
214+
v.isFieldValid(document.getElementById('field'), false)
215+
```
216+
217+
You can also supply a callback function to be run after the check.
218+
219+
```ts
220+
v.isFieldValid(document.getElementById('field'), true, myCallbackFn)
221+
```

0 commit comments

Comments
 (0)