0

I am trying to get the following form submission to show alert box if value is not equal to 'Province"

 function validate_form ( )
    {

    if ( document.contactForm.Province!='Region 1' )

    alert ( "Please Note: We only install in Region 1!" );

    }

My form name is "contactForm" my select menu is called "Province" I always get the alert here regardless of the selection in Province.

What am I doing wrong?

Grant
  • 2,413
  • 2
  • 30
  • 41

2 Answers2

1

You need to compare it to the value of that element:

 if ( document.contactForm.Province.value != 'Region 1' )
Joel Lundberg
  • 916
  • 5
  • 6
0

Try this

function validate_form ( )
{
    var temp = document.getElementbyId(Province);
    var strUser = temp.options[e.selectedIndex].text;
    if (strUser != 'Region 1' )
        alert ( "Please Note: We only install in Region 1!" );
}
Vishal Suthar
  • 17,013
  • 3
  • 59
  • 105