logo

NEW! Easy Image Loader - Working on. Open Source download coming soon.

Quickly process all forms on a page with Ajax. Just create the form(s), add data-process="ajax" to the <form> element, include the js file and the code below.
See demo and download example files below.

Basic script configuration

window.onload = function() {
	xForms.hookForms(
		function(text,button,formObj){
			
			// request is done do something
			
			button.style.cursor = 'pointer';
			button.value = 'Processed';
			alert(text); //response text
		},
		function(button,formObj){
		
		// on form submit do something
		
			button.style.cursor = 'wait';
			button.value = 'Sending..';
			// get email element by ID and check if empty
			if(formObj.id == 'form1')
			{
				if(xForms.getE("email").value == '')
				{
					button.style.cursor = 'pointer';
					button.value = 'Submit';
					// return error and kill form request
					alert('email is required');
					xForms.killRequest();
				}
			}
		
		}
	);
}

Demo

Binding three forms

Email: * Pass:
Email: Pass:
Email: Pass:

Download

Download at FolderShed.com User: getsoft | Password: now

Copyright © 2013 James P. Malloy. All Rights Reserved.