Why does this not work, detecting empty form field

Results 1 to 2 of 2

Thread: Why does this not work, detecting empty form field

  1. #1
    Join Date
    Dec 1969

    Default Why does this not work, detecting empty form field

    Hi I am pretty new to using Jscript in ASP and this may seem like a stupid question so please bear with me...<BR><BR>I am trying, to detect whether or not a form field has been filled in using the following script:<BR><BR>&#060;%@ LANGUAGE="JSCRIPT" %&#062;<BR>&#060;%<BR>var todate;<BR>todate = Request.form("todate");<BR><BR>if(todate ==""){<BR>Response.write("To date is empty");<BR>//Todate is empty so give it a default value;;;<BR>todate = tdaydatefunction();//Function to generate today&#039;s date<BR>} else {<BR>//This test condition executes even though there is no value entered in the preceeding "todate" form field.<BR>Response.write("To date is not empty");<BR>}<BR><BR>//I tried this but it also does not work either<BR>if(!todate){<BR>Response.write("To date is empty");<BR>}<BR>//==================<BR>%&#062;<BR><BR>I also found it really interesting that if I did the following, nothing printed:<BR>Response.write(todate);<BR><BR>But if I did this:<BR>Response.write("This is " + todate);<BR>I got "This is undefined";<BR><BR>So the bottom line is how do I check for empty form fields?<BR><BR>Thanks<BR><BR>Dwane Lumley

  2. #2
    Join Date
    Dec 1969

    Default RE: Why does this not work, detecting empty form f

    in JScript, if you eant a string, use<BR><BR>Request.Form(elementName).item<BR><BR>check my site for a bunch of JScript ASP articles<BR><BR>j<BR>http://rtfm.atrax.co.uk/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts