Create HTML form using rules defined in JSON

shaneshanghai

New Member
How do I create my HTML form based on rules I have in JSON ?So I need to create a form like
vW97X.png
My rules are in JSON as follows;\[code\]{ "modules":[ { "type":"navigation", "container":"#header", "title":"Top Navigation", "attributes":{ "class":"topNavigation", "id":"topNavigation" } }, { "type":"content", "title":"Hi Welcome to mobile development", "subtitle":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "container":"#maincontent", "attributes":{ "class":"topContent" } }, { "type":"form", "title":"Registration Form", "action":"submit.aspx", "name":"registrationform", "container":"#maincontent", "attributes":{ "class":"registrationform" }, "fields":[ { "id":"firstname", "label":"First Name", "name":"fname", "type":"text", "value":"" }, { "id":"email", "label":"Email", "name":"email", "type":"text", "value":"" }, { "id":"countries", "label":"Country", "name":"countries", "type":"select", "options":[ { "value":"", "text":"Select Country" }, { "value":"in", "text":"India", "selected":"true" }, { "value":"us", "text":"United Stated" }, { "value":"uk", "text":"United Kingdom" }, { "value":"cn", "text":"Canada" } ] }, { "id":"submit", "name":"submit", "type":"submit", "value":"Submit" } ], "rules": { "fname" : "required", "email" : { "required": "true", "email": "true" } }, "messages": { "fname" : "Enter your firstname", "email" : { "required": "Please enter a valid email address", "minlength": "Please enter a valid email address" } } } ]}\[/code\]While I have used normal HTML/JS code to create such forms, I am not sure how to parse things/rules from JSON and then apply it to the HTML ?I need to create the DOM for the HTML using JS as well...Please provide me any similar references which I can have a look at.
 
Back
Top