Hi goddy128, thank you for your super fast reply. Just to make sure i have it right, is this how it will be added then
Code:
function validate_form() {
if (!ValidatePhoneNumber(document.second.HomePhone.value)) {
return false;
}
if(!ValidateZip(document.second.ZipCode.value))
{
return false;
}
if ( document.second.degreeLevel.selectedIndex == 0 )
{
alert ( "Please select degree level" );
return false;
}
if ( document.second.ProgramInterest.selectedIndex == 0 )
{
alert ( "Please select area of study" );
return false;
}
if ( document.second.LevelofEducationCompleted.selectedIndex == 0 )
{
alert ( "Please select level of education" );
return false;
}
if ( document.second.FirstName.value == '' )
{
alert ( "Please Enter a First Name" );
return false;
}
if ( document.second.LastName.value == '' )
{
alert ( "Please Enter a Last Name" );
return false;
}
if ( document.second.Address.value == '' )
{
alert ( "Please Enter a Address" );
return false;
}
if ( document.second.City.value == '' )
{
alert ( "Please Enter a City" );
return false;
}
if ( document.second.State.selectedIndex == 0 )
{
alert ( "Please Select a State" );
return false;
}
if(!ValidateName(document.second.FirstName.value))
{
return false;
}
if(!ValidateName(document.second.LastName.value))
{
return false;
}
function ValidatePhoneNumber(field) {
var valid = "0123456789";
var hyphencount = 0;
if (field.length != 10) {
alert("Please enter your 10 digits phone.");
return false;
}
for (var i = 0; i < field.length; i++) {
temp = "" + field.substring(i, i + 1);
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your phone. Please try again.");
return false;
}
}
return true;
}
if(!EmailValid(document.second.Email.value))
{
return false;
}
function ValidateZip(field) {
var valid = "0123456789";
var hyphencount = 0;
if (field.length!=5 ) {
alert("Please enter your 5 digit zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code. Please try again.");
return false;
}
}
return true;
}
function ValidateName(field)
{
var invalid="0123456789()-+=@#$%^&*!~`{}][|:;<>,?/";
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (invalid.indexOf(temp) != "-1") {
alert("Invalid characters in your name field. Please try again.");
return false;
}
}
return true;
}
function EmailValidate(emailAddr){
if(!emailAddr){return false; }
//trim email string
return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(emailAddr);
}
}
When i test it like the above code, it allows me to submit the form with out validating the email. So i can leave the email section blank and the form gets submitted. Maybe i am missing something.
Here is my html code for the email part
HTML Code:
<input name="Email" type="text" class="third_box" id="email_address" />
Thank you for your time in responding
Nim
Bookmarks