Showing posts with label Internet. Show all posts
Showing posts with label Internet. Show all posts

11/06/2015

Process HTML Form data, Validate it and Submit to the Server Using formlib.js - jQuery

formlib.js


My new JavaScript Library based on jQuery to Process, Validate and Submit HTML Forms





What if i tell you that, this can do the job of HTML Form Processing ( It can Validate input fields data as well as can Submit Form data to Server, When You submit the Form)

Why formlib.js

  • formlib.js is a JavaScript Library, based on jQuery.js and HTML markup is based on bootstrap.css
  • Lightweight and every parameter is Configurable
  • Can Inject Progressbar HTML markup bootstrap.css and Update it Automatically

How To Use

  • Include formlib.js into your webpage
  • Write HTML Markup (Bootstrap.css - form-horizontal class) for Your Form
  • Copy CSS Path to Form
  • Create a New Object of ProcessForm Class by passing CSS Path to Form
  • Define Configuration Object and call config method for ProcessForm Object
  • successCall is Important, actually this is a Function, that should be called when Form Successfully Processed and Submitted to the Server (Backend)
  • There is a Demo HTML file index.php that you can Download and test using PHP Server.

Download

formlib.js from github.com

Sample JavaScript Code

var i = new ProcessForm("#simpleform");
var j = {
    /* I do not want tooltips */
    "injectTooltip": false,
    /* I do not want to show BS Icons for OK and Cancel */
    "injectBSIcon": false,
    "successCall" : function(i){ console.log(i); },
    "errorCall": function(i){ console.log(i); },
    'progressbar': "#progressbar",
    'validator': {
        'name': {
            "func": 'isUserName',
            "msg": "Please, Enter a Valid User Name"
        },
        "email": {
            "func": "isValidEmail",
            "msg": "Please, Enter a Valid Email Address"
        }
    }
};
i.config(j);

Sample Bootstrap based HTML Form Code

<form action="/demo.php" class="form-horizontal0 " id="simpleform" method="POST" style="border:2px solid rgba(228, 45, 172, 0.6);">
<fieldset>
    <legend>Simple HTML Form</legend>
    <div class="form-group">
        <label for="name" class="control-label col-xs-1">Name</label>
        <div class="col-xs-4">
            <input type="text" class="form-control" name="name">
        </div>
    </div>
    <div class="form-group">
        <label for="first" class="control-label col-xs-1">First's</label>
        <div class="col-xs-4">
            <input type="text" class="form-control" name="first">
        </div>
    </div>
    <div class="clearfix"></div>
    <div class="form-group">
        <label for="last" class="control-label col-xs-1">Last's</label>
        <div class="col-xs-4">
            <input type="text" class="form-control" name="last">
        </div>
    </div>
    <div class="form-group">
        <label for="email" class="control-label col-xs-1">Email</label>
        <div class="col-xs-4">
            <input type="text" class="form-control" name="email">
        </div>          
    </div>
    <div class="clearfix"></div>
    <div class="form-group">
        <label for="file1" class="control-label col-xs-1">File1</label>
        <div class="col-xs-9">
            <input type="file" class="form-control" name="file1">
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-12" id="progressbar"></div>
    </div>
    <div class="form-group" style="max-width: 200px;margin: 5px auto;">
        <input id="simpleformsubmit" class="btn btn-primary btn-block" type="submit" name="Click" value="Submit">
    </div>
</fieldset>
</form> 



Formlib.js - By Shishtpal Singh

3/14/2014

save wepage as archive (*.mhtml) using google chrome or firefox

# In this post, i want to share some tips for those who love to save web-pages for their research or with a hope that they might need this web page for later reading purpose.

# You can also save any web page in PDF format, but i think this way is not best, because i really hate to edit PDF files, actually it's boring to extract content from a PDF document. but if you are working with a *.mhtml or *.maff file, this gives you many features to customize them and more interactive than PDF documents.

# The best way that i found, is that save your web-page as a single web_page_archive file, and if you are thinking why should i save my web page as a single web page archive file.

# Answer is quite simple, because you can manage that file easily rather that managing a html file along with a folder which contains file necessary for your html document.
for example, if you save a web page than you will notice that there will be a html file and a folder, say, ( index.html + index_file )
index_file is a folder which contains, images , javascripts, and css etc.

# if you save a webpage as a web page archive than you can open this with google chrome or internet explorer, without any addon, but if you are a firefox user that you have to download a addon for firefox which allow you to save a web page as mhtml and allows you to read mhtml file.

# google_chrome and its relatives.
>>> type 'chrome://flags' in chrome URL tab.
>>> search for 'save _______'
>>> you will see an option, 'save as mhtml'
>>> enable this option and restart google-chrome
>>> you are now able to read and write mhtml files.

# for firefox_users>>>
you have to download and install this addon, from this website.
this firefox addon allow you to save a web page in many formats, such as mhtml, maff, and other formats.
# minimal disk space.
# link to original web page.
# include everything in a single archive to display a full web page.
# a lot of features to play with them, i also love this addon.
( http://maf.mozdev.org/ )