Skip to content

A client side JavaScript utility class, combined with a node.js server side handler, to process and store form data in emails or databases.

License

Notifications You must be signed in to change notification settings

jhuangsoftware/FormHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FormHandler

A client side JavaScript utility class, combined with a node.js server side handler, to process and store form data in emails or databases.

Getting Started Client Side

Include Client Side JavaScript

<script src="javascripts/form-handler.js"></script>

Assign .submit to action button in <Form>

<form class="form-horizontal form-handler">
  ...
  <div class="btn btn-primary submit">Submit</div>
  ...
</form>

Initialize <Form> using .formHandler()

$('.form-handler').each(function () {
    $(this).formHandler({
        'action': 'email',
        'email': 'Zm9ybWhhbmRsZXIuZGVtb0BnbWFpbC5jb20=',
        'success': function (data) {
            console.log(data);
        },
        'error': function () {
            console.log('error');
        }
    });
});

JSON Configuration

action

  • email configures the form data to be sent via email user defined email
  • database configures the form data to saved to a backend database

email

Populate this field when email action is configured. Use https://www.base64encode.org/ to encode email address to avoid spam crawler.

success

A user defined function to process server response in event of successful form submission.

error

A user defined function to process server response in event of failed form submission.

Getting Started Server Side

Install Node.js

Install Node.js from https://nodejs.org/en/

Compile Node.js Project

cd [project directory]
npm install

Start Node.js

node ./bin/www

About

A client side JavaScript utility class, combined with a node.js server side handler, to process and store form data in emails or databases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published