Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:19:01+00:00 2026-06-17T23:19:01+00:00

How do I create my HTML form based on rules I have in JSON

  • 0

How do I create my HTML form based on rules I have in JSON ?

So I need to create a form like
enter image description here

My rules are in JSON as follows;

{
   "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"
                            }
            }
      }
   ]
}

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:19:02+00:00Added an answer on June 17, 2026 at 11:19 pm

    You can try something like this: http://jsfiddle.net/epk6Z/

    for fiddle i used a variable json

    $.each(json.modules, function (i, items) {
      $('<' + items.formElem + '/>').attr({
        "action": items.action,
            "name": items.name,
            "class": items.attributes.class
      }).appendTo('body');
      $('<h1/>').text(items.title).appendTo('.registrationform');
    });
    

    And in the ajax, this should be in the success function like this:

    success: function(data){
     $.each(data.modules, function (i, items) {
      $('<' + items.formElem + '/>').attr({
        "action": items.action,
            "name": items.name,
            "class": items.attributes.class
      }).appendTo('body');
      $('<h1/>').text(items.title).appendTo('.registrationform');
     });
    } 
    

    there are lot of other changes has to be made but this is just a shotest usage i did.

    json

    {
    "modules": [{
        "nav": "navigation",
            "container": "#header",
            "title": "Top Navigation",
            "attributes": {
            "class": "topNavigation",
                "id": "topNavigation"
        }
    }, {
        "page-content": "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"
        }
    }, {
        "formElem": "form", //<-----------i targeted this
            "title": "Registration Form",
            "action": "submit.aspx",
            "name": "registrationform",
            "container": "#maincontent",
            "attributes": {
            "class": "registrationform"
        }
        ...............
    

    note:

    Its not a full answer i just appended the form and the title of the form

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create an HTML form based on XML or JSON data
I need to create a CSV based on html form input. I have it
I have this JSON object that I am trying to create an html form
How can I create a helper like the Html.Form helper, which closes the tag
I'd like to be able to create a javascript object from my html form
i have create a form (so it's PHP and HTML hybrid-code). it has ability
I create a form based on a model , like seen below: class ContactSelectionForm(forms.ModelForm):
For a custom image selection tool I would like to create form validation based
I have a <select> form element where I create multiple <option> children based on
For my html form, it seems that I'm unable to create cross browser hover

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.