This commit is contained in:
orangemug 2015-04-28 12:08:46 +01:00
parent b1b3fdcce8
commit 3185b12083
2 changed files with 35 additions and 1 deletions

View File

@ -200,9 +200,13 @@ schema.properties.notIn = function(value, badwords)
}
```
## Browser usage
You can use it in the browser by using [browserify](http://browserify.org/), however if that's too much work just use <https://wzrd.in/>. There is also an example <examples/cdn.html>
# ideas
- make it work in the browser for client side validation
- strict mode, dissallowing extra parameters from being passed in
- dependency property making one parameters existance depend on another
- more types (phone numbers, credit card, ip address)

30
examples/cdn.html Normal file
View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>https://wzrd.in - schemajs example</title>
</head>
<body>
<p>See the console and view the source for details</p>
<script type="text/javascript" src="https://wzrd.in/standalone/schemajs@latest"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Example from the README
// NOTE: You'll have to use `window.schemajs`
var model = window.schemajs.create(
{
name: {type:"string", filters:"trim", properties:{max:255}, required:true},
email: {type:"email", filters:"trim", required:true},
wins: {type:"int", filters:["trim", "toInt"], default:0},
average: {type:"float", filters:["trim", "toFloat"], default:0}
});
var form = model.validate({name:" your name ", email:" name@example.com "});
console.log(form);
});
</script>
</body>
</html>