 /*
* This is the JavaScript function that checks for correct phone input. Note that
* this script defines the checknumber() function called by the event
* handlers in the form. The function reads values from the form
* <input> fields using the names defined in the index.php code.  It outputs
* its results into the named <span> elements.

Notes: I pondered various ways to check for phone number and decided to go with this one below. I did not check for international formats since my service will not include international numbers. Therefore this makes things easier as most US phone numbers have only 10 digits. 
*Written by Alan Galiwango
*Aug. 6 2007
*/
function checknumber() {

//Get the actual phone number from the document and call it number
var number = document.emailform.phone.value;
// Get named <span> elements from the form.
var phone = document.getElementById("phone");
  
var stripped = number.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
    phone.innerHTML = "The phone number contains illegal characters.";
}
else if (!(stripped.length == 10)) {

    //display the results by setting the HTML content of each <span> element.
	phone.innerHTML = "The phone number is the wrong length.";
}
else phone.innerHTML = "<img src='green_tick.gif' />";//ths is how u insert an image in innerHTML javascript. I  had to look it up on the web
	
}




