There IS a bug

admin

Administrator
Staff member
I REALLY FEEL LIKE SMASHING THE GUY WHO INVENT JAVASCRIPT!

Another look at my js code would make me vomit! If somebody have any ideas why, would be very much appreciated.

The Problem:



[HTML Form]
<form name="frm" id="frm" method="post" onsubmit="return checkForm(this)">

<input name="name" type="text" id="name">

<select name="country">
<option value=http://www.webdeveloper.com/forum/archive/index.php/"">Select A Country</option>
<option value="SGP">Singapore</option>
<option value="USA">United States</option>
<option value="MYS">Malaysia</option>
<option value="AFG">Afghanistan</option>
<option value="ALB">Albania</option>
</select>

<input name="email" id="email" type="text">

<input name="phone" type="text" id="phone">





[Javascript Code]
function checkForm( frm )
{

if ( frm.title.value =='' )
{
alert( "Error: Please specify your title" );
frm.title.focus( );
return false;
}

if ( frm.name.value == '' )
{
alert( "Error: Please enter your name" );
frm.name.focus( );
return false;
}

if ( frm.country.value == '' )
{
alert( "Error: Please specify your country" );
frm.country.focus( );
return false;
}

if ( frm.email.value == '' )
{
alert( "Error: Please enter your email address" );
frm.email.focus( );
return false;
}

if ( frm.phone.value == '' )
{
alert( "Error: Please enter your phone no." );
frm.phone.focus( );
return false;
}

if ( frm.projsum.value == '' )
{
alert( "Error: Please enter your project summary" );
frm.projsum.focus( );
return false;
}

}



Javascript only validate the name and country and a textfield (projsum), while no matter what, email and phone can never be prompt! When I set

if ( frm.email.value == null ) <--- instead

It prompt, but when I click ok, the form gets submitted. damn i really can't figure out, javascript is so much full of bugs and is so sensitive unlike serverside codes.
 
Back
Top