?
Solved

Validating text input into a numeic field

Posted on 2000-05-17
5
Medium Priority
?
241 Views
Last Modified: 2013-12-18
Hello,

Ive got a validation question for you.

On a form I want to validate that the value entered into a numeric field is actually a numeric.

Ive looked at the input validation section but that only seems to check on a save. I need to check as soon as someone leaves the field.

So...what Ive done is put some script into the Exiting event.

Ive got this...

Sub Exiting(Source As Field)
     
     Dim ws As  New NotesUIWorkspace
     Dim doc As NotesDocument
     
     Set uidoc = ws.CurrentDocument
     Set doc = uidoc.document
     
     If (Isnumeric(doc.annualdays(0)) = True) Then
          End
     Else
          Msgbox "You must enter a numeric value for this field",48,"Numeric Field Error"
     End If
End Sub


Now this works ok if you have a space or number in the field, but if you put a character in - 'a' for instance, then the script generates an error to the effect of "Variant does not contain a container"

Obviously this isnt an ideal error message for users...

Does anyone know how I can accomplish this?

Many thanks,

Mat
0
Comment
Question by:prenexus
[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
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 2819789
Hi Mat

The numeric fields always validate for numeric values, this is the default behavour, if it is a text value  then it will prompt u with the error message.

For that you must enable "automatically refresh field" in the form properties. If u do so then user is prompted with error msg saying that the value is incorrect.

Good luck
~Hemanth

0
 
LVL 2

Accepted Solution

by:
Antonysingh earned 400 total points
ID: 2823700
Hi prenexus,

Use a error handler in your code as shown in the following code, this will handle the error.

Dim ws As  New NotesUIWorkspace
      Dim doc As NotesDocument

       'Error handler
      On Error Goto errhand

      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.document
      
      If (Isnumeric(doc.annualdays(0)) = True) Then
            End
            
      End If

'Error handle section.
      
errhand:
      Msgbox "You must enter a numeric value for this field",48,"Numeric Field Error"
      Call uidoc.gotofield("annualdays")
      Exit Sub


Hope this may help you.
Good luck,

-Antony.
0
 

Author Comment

by:prenexus
ID: 2823773
HemanthaKumar,

Thanks for the answer - and while it does provide a solution its not really what I was looking for.

Thanks,

Mat
0
 

Author Comment

by:prenexus
ID: 2823777
Antony,

Thanks for the comment! Thats exactly what I was looking for.
Whats more youve shown me a way to highlight the field that was causing the trouble as well.

Mat
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 2827908
That's OK.

May be I don't know the whole picture, and Antony got it.

~Hemanth
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  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…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 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