Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 19th, 2006, 09:23 AM
Authorized User
Points: 245, Level: 4
Points: 245, Level: 4 Points: 245, Level: 4 Points: 245, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: Houston, TX, USA.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ricespn
Default Form Validation


Hi,

I'm trying to validate a form using JavaScript and I'm having a hard time to grasp the language I cannot get it to pass the second IF statement, unless everything is filled. But if I return true
then it ignores the other fields.

Here is the script:

 function ValidateFormEdit(frmEdit)
{
if (""==document.forms.frmEdit.lpartno.value)
    {alert("PART NUMBER is a required field.");
    document.forms.frmEdit.lpartno.focus();
    return false;}

if (""==document.forms.frmEdit.lrefpartno.value)
    {var answer = confirm("Leaving REFERENCE PART blank will disable the SKU");

        if (answer==true)
            {document.forms.frmEdit.lrefpartdesc.value="";
             document.forms.frmEdit.lstatus.value="REMOVE";
             document.forms.frmEdit.ldisabled.value=0;
             return false;
            }
        else
            {document.forms.frmEdit.lrefpartno.focus();
            return false;}
    }

if (""==document.forms.frmEdit.lrefqty.value)
    { alert("QTY is required");
      document.forms.frmEdit.lrefqty.focus();
      return false;}

if (""==document.forms.frmEdit.lfactoryid.value)
    { alert("Please select a BU.");
      document.forms.frmEdit.lfactoryid.focus();
      return false;}

if (""==document.forms.frmEdit.lskuno.value)
    {var skuanswer=confirm("Leaving SKU blank will map this to the whole BU.");

        if (skuanswer==true)
            {document.forms.frmEdit.lskuno.value="#ALL#";
            return false;}
        else
            {document.forms.frmEdit.lskuno.focus();
            return false;}
  }

  if (""==document.forms.frmEdit.lfromdate.value)
    { alert("FROM DATE is required.");
      document.forms.frmEdit.lfromdate.focus();
      return false;}

if (""==document.forms.frmEdit.ltodate.value)
    { alert("TO DATE is required.");
      document.forms.frmEdit.ltodate.focus();
      return false;}
}

Strange and crazy, but everything is possible
__________________
=======================
Strange and crazy, but everything is possible
Reply With Quote
  #2 (permalink)  
Old October 19th, 2006, 09:31 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok since I dont know your business rules I can't break down the code, but you can so here is the 35,000 foot view. When you use return in a function, it stops the process false means the function failed, true means it passed.

What you should do, is right before the closing brace of your function add a return true; What this will do is, if all the if's are skipped over, the function returns true and the form submits else the javascript will return false and the form wont submit.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
Reply With Quote
  #3 (permalink)  
Old October 19th, 2006, 11:33 AM
Authorized User
Points: 245, Level: 4
Points: 245, Level: 4 Points: 245, Level: 4 Points: 245, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: Houston, TX, USA.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ricespn
Default

:D

Thanks Man!

That worked like a charm.. I can't belive it was just that...

Quote:
quote:Originally posted by dparsons
 Ok since I dont know your business rules I can't break down the code, but you can so here is the 35,000 foot view. When you use return in a function, it stops the process false means the function failed, true means it passed.

What you should do, is right before the closing brace of your function add a return true; What this will do is, if all the if's are skipped over, the function returns true and the form submits else the javascript will return false and the form wont submit.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
Strange and crazy, but everything is possible
Reply With Quote
  #4 (permalink)  
Old October 19th, 2006, 11:38 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No worries glad it worked for you.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Form Validation Stanny Access VBA 5 December 20th, 2005 08:13 PM
Validation of Form qazi_nomi Javascript 5 August 2nd, 2004 03:49 PM
Form not refreshing after form validation Mimi Javascript How-To 0 August 25th, 2003 03:20 AM



All times are GMT -4. The time now is 04:35 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.