OKAY I found the answer to my problem... Most browsers would detect the value of the option fields automatically meaning what I originally had was this:
<select name ="Service">
<option>NOCC</option>
<option>HVAC</option>
....etc.
</select>
however IE was always getting null values since I didn't explicitly specify the value attribute to the element tag. So all I did was change my code from that on top to the following:
<select name="Service">
<option value="NOCC">NOCC</option>
<option value="HVAC">HVAC</option>
....etc..
</select>
and now works fine in IE. Strange enough most browsers are able to detect the value attribute by looking at the option tag display however IE requires that you specifically define the value attribute otherwise will look at it as blank or null. and that's why my if clause was failing in IE because i didn't specify the value attribute and hence it was always blank even when I did choose a value from the drop down menu it still saw it as blank.
thank you all for your help I definately benefited by learning something new from your posts like JQuery.
cheers
-------------------멋진 jQuery 크로스 브라우저 솔루션이 있으며 이메일 주소, 날짜 및 기타 일반적인 기능에 대한 유효성 검사를 제공합니다. 오류를 표시 할 수있는 공통 div를 정의 할 수 있습니다.
나는 이것을 Asp.net과 함께 사용했으며 내 필요에 맞게 조정하는 데 거의 어려움이 없었습니다. 여기에이 솔루션을 사용한 사용자가 꽤 있습니다.
-------------------먼저 alert
작성하지 않고 일반 함수처럼 호출해야합니다 javascript:
.
그러나 문제는 IE value
가 select
요소에 대한 속성을 다르게 구현한다는 것 입니다.
옵션의 selected
속성이 인지 확인해야합니다 true
.
다음 과 같이 jQuery를 사용하는 것이 가장 쉽습니다 .
if ($('#service').val() === ""
|| $('#somethingElse').val() === "") {
alert("Please enter all necessary fields.");
return false;
} else
return true;
-------------------함수 javascript:
앞에 둘 필요가 없습니다 alert();
.
출처
https://stackoverflow.com/questions/2003786