Solved

Field Validation Not working

Posted on 2006-07-13
3
236 Views
Last Modified: 2010-04-30
Hi,
I'm using vbsript in an HTML page.  I want to first determine if the texbox (AGE) is empty and then determine if the value used is only numeric.  If numeric does the number fall between 0 and 64, then I will set the value to to form17.   I think it's the IsNumeric function and nested If statment that is causing the problem.  Is there a better way to do this? I have assigned 500 point value because the request urgent.   As always, thanks for your help!  


Example:
form17 = main.AGE.value
      If IsEmpty(main.AGE.value) Then
         MsgBox ("CAN NOT CONTINUE - MISSING AGE")
         Exit Sub
      ElseIf len(main.AGE.value) = 0 Then
         MsgBox ("CAN NOT CONTINUE - MISSING AGE")
       Exit Sub
      ElseIf IsNumeric(main.AGE.value)
            If (main.Age.Value) > 0 And <= 64
                     form17 = main.AGE.value
                  Else
                     MsgBox ("CAN NOT CONTINUE - AGE MUST BE BETWEEN 0 AND 64")
                  Exit Sub
            End If
      Else
         MsgBox ("CAN NOT CONTINUE - USE ONLY NUMERIC VALUES FOR THE AGE")
         Exit Sub
      End If
0
Comment
Question by:MoJeaux39
[X]
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
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 17104224
There are a couple of syntax errors in this block:

      ElseIf IsNumeric(main.AGE.value)
          If (main.Age.Value) > 0 And <= 64
                   form17 = main.AGE.value
                Else
                   MsgBox ("CAN NOT CONTINUE - AGE MUST BE BETWEEN 0 AND 64")
               Exit Sub
          End If

Whether these are just paste errors or typos, but it should say:

      ElseIf IsNumeric(main.AGE.value) Then
          If (main.Age.Value) > 0 And (main.Age.Value) <= 64 Then
                   form17 = main.AGE.value
                Else
                   MsgBox ("CAN NOT CONTINUE - AGE MUST BE BETWEEN 0 AND 64")
               Exit Sub
          End If
0
 
LVL 9

Expert Comment

by:smidgie82
ID: 17104249
Hi MoJeaux39,

Is this the exact code you're using?  are you getting a particular error message?  I see a few syntax errors that, in the absence of more information, I assume could be causing your problem.  Try the following:

form17 = main.Age.Value
      If IsEmpty(main.Age.Value) Then
         MsgBox ("CAN NOT CONTINUE - MISSING AGE")
         Exit Sub
      ElseIf Len(main.Age.Value) = 0 Then
         MsgBox ("CAN NOT CONTINUE - MISSING AGE")
      Exit Sub
      ElseIf IsNumeric(main.Age.Value) Then
          If (main.Age.Value > 0) And (main.Age.Value <= 64) Then
                   form17 = main.Age.Value
                Else
                   MsgBox ("CAN NOT CONTINUE - AGE MUST BE BETWEEN 0 AND 64")
               Exit Sub
          End If
      Else
         MsgBox ("CAN NOT CONTINUE - USE ONLY NUMERIC VALUES FOR THE AGE")
         Exit Sub
      End If


Note the addition of "Then" at the end of an "ElseIf" and the following "If" lines.  And the reformatting of your "If (main.Age.Value) > 0 And <= 64" line.

Cheers!
0
 

Author Comment

by:MoJeaux39
ID: 17104274
Thank you for the prompt response!  It's unfortunate, but they were typo's in the script.  I works fine now.  =)  
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month4 days, 3 hours left to enroll

630 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