Form validation

Hi Experts

I have a form with fields I need to validate based on the users selection like so.

The fields involved are E12, E13, E14 and E15.

The logic needs to be

 E12 = 02 or 05, E13 needs to be 98, E14 needs to be 99, E15 needs to be 99.

 E12 = 04, E13 needs to be 03, E14 needs to be 01, 02, 03, 04, 05, E15 needs to be 99.

 E12 = 03, E13 needs to be 01 or 02, E14 needs to be 99, E15 needs to be 02.

 E12 = 01 E13 needs to be 01 or 02, E14 needs to be 99, E15 needs to be 01, 02, 03.

Any 1 of the above is valid and the form should be submitted anything else should be thrown back with an error message.

I previously submitted this problem and got a good solution but I assumed I would be able to nest this solution in order to expand it and cover all the options this gave me a very obscure error message.

Previous question
http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21422294.

So I am reposting in the hope someone can help as I am running out of time and finding this the hardest part of my application.

Any help would be greatly appreciated.

Thanks

Clive
html
clivecrawdevilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cyberdevil67Commented:
This is off the top of my head.

<cfset Contine = false>
<cfswitch expression="#E12#">
 <cfcase value="02,05" delimiters=",">
  <cfif e13 eq 98 and e14 eq 99 and e15 eq 99>
            <cfset Contine = true>
      </cfif>
 </cfcase>
 <cfcase value="04">
      <cfif e13 eq 3 and "01,02,03,04,05" contains e14 and e15 eq 99>
            <cfset Contine = true>
      </cfif>
 </cfcase>
 <cfcase value="03">
            <cfif (e13 eq 01 or e13 eq 02) and e14 eq 99 and e15 eq 02>
                  <cfset Contine = true>
            </cfif>
 </cfcase>
 <cfcase value="01">
            <cfif (e13 eq 01 or e13 eq 02) and e14 eq 99 and "01,02,03" contains e15>
                  <cfset Contine = true>
            </cfif>
 </cfcase>

</cfswitch>
0
clivecrawdevilAuthor Commented:
Hi Cyberdevil67

Getting this error String index out of range: -2

same as when i nested if statements in my previouse attempt

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21422294

any idea what this message means?

Clive
0
cyberdevil67Commented:
That link doesn't exist anymore.

Which line is erroring
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

cyberdevil67Commented:
which version of coldfusion are you using?
0
clivecrawdevilAuthor Commented:
Sorry my bad.

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21422294.html

think the link was broken because it was missing html extenstion.

That is the entire error message. Even with robust exception and debugging enabled.
0
clivecrawdevilAuthor Commented:
MX 7
0
cyberdevil67Commented:
This works for me

<cfparam name="E12" default="05">
<cfparam name="E13" default="98">
<cfparam name="E14" default="99">
<cfparam name="E15" default="99">

<cfset Contine = false>
<cfswitch expression="#E12#">
      <cfcase value="02,05" delimiters=",">
            <cfif e13 eq 98 and e14 eq 99 and e15 eq 99>
                  <cfset Contine = true>
            </cfif>
      </cfcase>
      <cfcase value="04">
            <cfif e13 eq 3 and "01,02,03,04,05" contains e14 and e15 eq 99>
                  <cfset Contine = true>
            </cfif>
      </cfcase>
      <cfcase value="03">
            <cfif (e13 eq 01 or e13 eq 02) and e14 eq 99 and e15 eq 02>
                   <cfset Contine = true>
            </cfif>
      </cfcase>
      <cfcase value="01">
            <cfif (e13 eq 01 or e13 eq 02) and e14 eq 99 and "01,02,03" contains e15>
                  <cfset Contine = true>
            </cfif>
      </cfcase>
</cfswitch>

<cfdump var="#Contine#">
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clivecrawdevilAuthor Commented:
This was the return when i put it in with my code.


false





Error Occurred While Processing Request  
String index out of range: -2  
 
 
Please try the following:
Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debugging Settings, and select the Robust Exception Information option.
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.

 
Browser   Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Remote Address   192.168.0.24
Referrer    
Date/Time   16-May-05 02:04 PM
 
 
0
cyberdevil67Commented:
Have you got robust Excpetion switch on?

I tested the code I posted on MX 7.0 running here on windows XP, and Windows Server 2000, and Windows Server 2003 and it works.

If you are getting the false then the problem is further in the code. by switching on the robust Excpetion it will give you more detailed info.
0
clivecrawdevilAuthor Commented:
Could it be the way i am implementing the code?

I have this sitting above my insert query, so if it checks out ok the record is saved to the database.
0
cyberdevil67Commented:
Do the switch Robust Exception on in the debbuging like the error message tells you to do.
0
clivecrawdevilAuthor Commented:
Got it was a problem with the primary key.

Thanks alot thats great, works well.

Just one more question if you have time, how would i show the error?

Would i put it in <cfset Contine = false> or would it be better to use a cflocation to redirect to an error page?

Clive

0
cyberdevil67Commented:
<cfif Contine>
 Insert into database
<cfelse>
 Display Error
</cfif

yes you could do relocation if you want.
0
clivecrawdevilAuthor Commented:
Excelent

Thanks alot cyberdevil!

Points well deserved.

Clive
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.