Inspect form data in javascript

10/04/17

Permalink 04:00:18 pm, by Greg, 72 words, 26 views   English (CA)
Categories: Activity log; Mins. worked: 20

Inspect form data in javascript

Debugging a form got a bit easier with the FormData() method in javascript.

Insert function like:

function inspectFormData(formId){
	var formElement = document.getElementById(formId);
	var formData = new FormData(formElement);
	console.log('FIELDNAME: Value');
	for (var pair of formData.entries()) {
		console.log(pair[0]+ ': ' + pair[1]);
	}
}

And it’ll deliver this:

FIELDNAME: Value
METHENL: E
SURNAME: Adams
FORENAME: Charles Frederick
ADDRESS: 
MILSERACT: 
POB: Toronto, Ontario
NONOK: 
AONOK: 
RONOK: 
OCC[]: 
HISCO[]: 
DUGUID[]: UN
MARRIED: N

Pingbacks:

No Pingbacks for this post yet...

CGWP

Reports

XML Feeds