function verify(contact) {
	//check to see if the name field is blank
	if (contact.name.value == "") {
        alert("Please enter your name.")
		contact.name.focus()
		contact.name.select()
		return false
	}
	//check the email address using validEmail function
	if (!validEmail(contact.email.value)) {
		alert("You must enter a valid email address.")
		contact.email.focus()
		contact.email.select()
		return false
	}	
	//check the email address using validEmail function
	if (!validPhone(contact.phone.value)) {
		alert("You must enter a valid phone number.")
		contact.phone.focus()
		contact.phone.select()
		return false
	}		
	//check to see if the song title field is blank
	if (contact.song_title.value == "") {
        alert("Please enter the song title.")
		contact.song_title.focus()
		contact.song_title.select()
		return false
	}
	//check to see if the genre field is blank
	if (contact.genre.value == "") {
        alert("Please enter the song's genre.")
		contact.genre.focus()
		contact.genre.select()
		return false
	}

}	
// Check email address
function validEmail(email) {
		invalidChars = " /:,;"
		
		if (email == "") {
			// cannot be empty
			return false
		}
		 for (i=0; i<invalidChars.length; i++) {
		 	// does it contain any invalid characters?
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		// there must be one "@" symbol
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) != -1) {
			// and only one "@" symbol
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			// and at least one "." after the "@"
			return false
		}
		if (periodPos+3 > email.length)	{
			// must be at least 2 characters after the "."
			return false
		}
		return true;
	}
// Check phone
function validPhone(phone) {
		invalidChars = ":,;`~!@#$%^&*_=[]{}\|/<>.+abcdefghigklmnopqrstuvwxyz"
		// check for bad charcters
		for (i=0; i < invalidChars.length; i++) {
		 	// does it contain any invalid characters?
			badChar = invalidChars.charAt(i)
			if (phone.indexOf(badChar,0) > -1) {
				return false
			}
		}
		// at least 9 characters
		if (phone.length < 9)	{
			return false
		}
		return true;
	}
