Jump to content

how to get length of a form field using NAME


jasonc

Recommended Posts

this is my code now, but i can not work out how to actually check that the field have data or not as all fields get a green tick placed even if it is empty.

 

function checkValidFormInput() {

					if (document.getElementsByName('customerName').value != '') {
					document.getElementById('customerNameImg').innerHTML = '<img alt="Valid" src="images/greenTick.png">';
					} else {
					document.getElementById('customerNameImg').innerHTML = '<img alt="Invalid" src="images/redX.png">';
					}

					if (document.getElementsByName('customerEmail').length > 0) {
					document.getElementById('customerEmailImg').innerHTML = '<img alt="Valid" src="images/greenTick.png">';
					} else {
					document.getElementById('customerEmailImg').innerHTML = '<img alt="Invalid" src="images/redX.png">';
					}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.