Last change
on this file since 492 was
492,
checked in by hendrikvanantwerpen, 11 years ago
|
- Enable/disable buttons on content change.
- One place to do date formatting, because it was going wrong again.
- Serialize questions in survey properly.
- _ComplexValueMixin consumes submit events, but does trigger outer
forms if present.
- Trigger dialog show/hide for login only after previous effect is
finished.
- Check that documents are actually valid, not just that validator
returned a result.
- Validate email and timestamp formats.
- Prepared for live runs.
|
File size:
803 bytes
|
Line | |
---|
1 | var tv4 = require('tv4'); |
---|
2 | |
---|
3 | // from: http://www.w3.org/TR/html5/forms.html#valid-e-mail-address |
---|
4 | var html5EmailRe = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; |
---|
5 | var datetimeRe = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z/; |
---|
6 | |
---|
7 | tv4.addFormat({ |
---|
8 | email: function(data){ |
---|
9 | if ( typeof data === "string" && html5EmailRe.test(data) ) { |
---|
10 | return null; |
---|
11 | } else { |
---|
12 | return "Probably an invalid email address."; |
---|
13 | } |
---|
14 | }, |
---|
15 | datetime: function(data){ |
---|
16 | if ( typeof data === "string" && datetimeRe.test(data) ) { |
---|
17 | return null; |
---|
18 | } else { |
---|
19 | return "Invalid timestamp."; |
---|
20 | } |
---|
21 | } |
---|
22 | }); |
---|
23 | |
---|
24 | module.exports = tv4.validateResult.bind(tv4); |
---|
Note: See
TracBrowser
for help on using the repository browser.