aspnet-client-validation
Advanced tools
Comparing version 0.4.0 to 0.5.0
{ | ||
"name": "aspnet-client-validation", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Enables ASP.NET MVC client-side validation, without jQuery!", | ||
@@ -5,0 +5,0 @@ "main": "dist/aspnet-validation.js", |
@@ -49,3 +49,3 @@ # ASP.NET Client Validation | ||
require('core-js'); | ||
const aspnetValidation = require('aspnet-validation'); | ||
const aspnetValidation = require('aspnet-client-validation'); | ||
@@ -60,3 +60,3 @@ let v = new aspnetValidation.ValidationService(); | ||
import 'ts-polyfill'; | ||
import { ValidationService } from 'aspnet-validation'; | ||
import { ValidationService } from 'aspnet-client-validation'; | ||
@@ -131,3 +131,3 @@ let v = new ValidationService(); | ||
```ts | ||
import { ValidationService } from 'aspnet-validation'; | ||
import { ValidationService } from 'aspnet-client-validation'; | ||
let v = new ValidationService(); | ||
@@ -176,3 +176,3 @@ | ||
```ts | ||
cost form = document.getElementById('form'); | ||
const form = document.getElementById('form'); | ||
form.addEventListener('validation', function (e) { | ||
@@ -182,1 +182,45 @@ /* Check if form is valid here. */ | ||
``` | ||
## Programatically validate a form | ||
```ts | ||
v.validateForm(document.getElementById('form')); | ||
``` | ||
## Checking form validity | ||
```ts | ||
v.isValid(document.getElementById('form')) | ||
``` | ||
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: | ||
```ts | ||
v.isValid(document.getElementById('form'), false) | ||
``` | ||
You can also supply a callback function to be run after the check. | ||
```ts | ||
v.isValid(document.getElementById('form'), true, myCallbackFn) | ||
``` | ||
## Checking field validity | ||
Similar to checking a forms validity, you can check individual fields too. | ||
```ts | ||
v.isFieldValid(document.getElementById('field')) | ||
``` | ||
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: | ||
```ts | ||
v.isFieldValid(document.getElementById('field'), false) | ||
``` | ||
You can also supply a callback function to be run after the check. | ||
```ts | ||
v.isFieldValid(document.getElementById('field'), true, myCallbackFn) | ||
``` |
111004
221