HTML5 date input control custom validation based on JSON Schema -


in application using backbone, have json object tells display html5 controls,

     "items": [                 { "key": "user.fname", "title" : "first name" },                 { "key" : "user.lname", "title": "last name" },                 {                     "key": "user.dateofbirth",                     "title": "date of birth",                     "type": "date"                 },                  {                     "type": "submit",                     "title": "check",                     "htmlclass": "chkbtn"                 }             ] 

and value entered user validated using json schema,

"user" : {          "required" : true,          "minitems" : 1,          "properties" : {                     "fname" : { "required": true, "title" : "first name", "type" : "string"},                       "lname" : { "required": true, "title" : "last name", "type" : "string"},                                               "salutation" : { "required": false, "title" : "salutation", "type" : "string"},                     "dateofbirth" : { "required": true, "title" : "date of birth", "type" : "string"}         } 

the required field validation working fine. need have age restriction validation age must 18 or older. how can add custom validation json schema triggered in ui?

thanks in advance.

backbone view code.

render: function () {              // code add form template el              this.jsonform = $("form").jsonform({                 "schema": schema,                 "form": options,                 "value": vals             });           },          submit: function (e) {              var self = this;              var err = this.jsonform.validate();              if (!err.errors) { // code persist} } 


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -