Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JS validation causes error when opening

Posted on 2004-03-24
4
258 Views
Last Modified: 2013-12-18
case "Pending Approval" :
                                               TK = "Time Keeper Project Code/TKProjCode"
                                               if ( document.all.RequestType.value !== "RFA" )
                                              elseif( !RTGValidateForm(TK ) )
                    return false
               v = "Forecast Effort (mandays)/Effort, Proposal Valid Thru/DateValidThru, Scheduled Start/DateScheduledStart, Committed Delivery/DateCommittedDelivery, Engineering Group/EngineeringGroup"
               if ( document.all.RequestType.value == "Certification" ) v += ",Engineer Contact Name/CertEngineer,Engineer Contact Phone/CertPhone,Engineer Contact E-Mail/CertEmail"
               if ( !RTGValidateForm( v ) )
                    return false
               break
0
Comment
Question by:adspmo
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 10672070
Hi adspmo,
>                                               if ( document.all.RequestType.value !== "RFA" )
>                                               elseif( !RTGValidateForm(TK ) )


This looks wrong.  Here are the possible syntax variations for JS if statements:

if ( condition )
    single_statement


if ( condition ) {
    first_statement
    seoncd_statement
}


if ( condition )
    single_positive_statement
else
    single_negative_statment


And of course, single_positive_statement and/oor single_negative_sttament could easily be turned into multiple statements by replacing teh single statment with braces-enclosing-several.

So, first off, there is no statement after your if, so JS will think the elseif is supposed to be an exevutable statement.  Second, there should be a space between else and if, because JS doesn't use elseif.

Cheers!
0
 

Author Comment

by:adspmo
ID: 10672234
Ok I tried to slim it down. Myintent is to validate all forms but the RFA=Problem Rpt
Case: Pending Approval
  if ( document.all.RequestType.value == "RFA-Problem Rpt" )
                                      if ( !RTGValidateForm() )
                        return false      
                  v = "Forecast Effort (mandays)/Effort, Proposal Valid Thru/DateValidThru, Scheduled Start/DateScheduledStart, Committed Delivery/DateCommittedDelivery, Engineering Group/EngineeringGroup,Time Keeper Project Code/TKProjCode"
                  if ( document.all.RequestType.value == "Certification" ) v += ",Engineer Contact Name/CertEngineer,Engineer Contact Phone/CertPhone,Engineer Contact E-Mail/CertEmail"
                  if ( !RTGValidateForm( v ) )
                        return false
                  break
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 500 total points
ID: 10672495
adspmo,
Just look at your structure!

If RFA then
    if not valid Then
        return false
    end if
end if

That ONLY validates the RFA, the opposite of what you said!

I think you want something like:

If RFA Then
    return true


'Now we know we are not RFA, so validate
v = "list of fields to validate"
etc.

Also, I don't understand the RTGValidateForm function.  You have it called both with and without a parameter.  I assume that when you pass it a parameter, it assumes the parameter to be a string it can split at comma, and take each value and check whether it was filled in or not.
0
 

Author Comment

by:adspmo
ID: 10673429
It was the return true

Hey I learned something

Thanx

James
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question