Jscript Quicke

  • Thread starter Thread starter Craig G
  • Start date Start date
C

Craig G

again novice attack here

how in javascript can i check the value of a field then if its null throw an
alert then exit out of the function

this is my attempt, but it wont work:-

if (document.getElementById('txtAddress2')=null) window.alert("Town must be
populated") return;

Cheers,
Craig
 
Hi,

Use double '=' (==) for comparision:

if (document.getElementById('txtAddress2') == null) {}


again novice attack here

how in javascript can i check the value of a field then if its null throw an
alert then exit out of the function

this is my attempt, but it wont work:-

if (document.getElementById('txtAddress2')=null) window.alert("Town must be
populated") return;

Cheers,
Craig
 
I assume you are wanting the check the "value" of the text box.

control = document.all["txtAddress2"];
if ( control.value == "" )
alert( "Town must be populated." );

HTH,

bill
 
Back
Top