Help with numeric validation using VBScript - InfoPath Dev
in

InfoPath Dev

Help with numeric validation using VBScript

Last post 07-10-2011 11:27 AM by Jimmy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-08-2009 05:42 AM

    Help with numeric validation using VBScript

    I'm having trouble getting this VBScript validation to work. Its a numeric field and I want it to validate between 75 and 125. At the minute I can enter any number, but no errors ever come up. Can anyone see what im doing wrong?? Thanks

    Dim pcm 

    Sub msoxd_my_PCMNumber_OnValidate(eventObj)

     pcm = XDocument.DOM.selectSingleNode("my:myFields/my:OverallSummary/my:PCMNumber").text
     
     If pcm < 75 and pcm > 125 Then
      eventObj.ReturnMessage = "Please enter a PCM number between 75 and 125!"
      eventObj.ReturnStatus = False
      Exit Sub
     End If

    End Sub

  • 07-10-2011 10:35 AM In reply to

    Re: Help with numeric validation using VBScript

    Hi clinter i recently stumbled across http://rindovincent.blogspot.com/p/vbscript-programs.html where there was a simple program to validate Numeric value in VBScript. I hope it will solve your problem just change the number in that program. It is very easy to understand and with the permission of that blog i am pasting that program

    <HTML>
    <HEAD><TITLE>Simple Validation</TITLE>
    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub Submit_OnClick
      Dim TheForm
      Set TheForm = Document.ValidForm
      If IsNumeric(TheForm.Text1.Value) Then
        If TheForm.Text1.Value < 18 Or TheForm.Text1.Value > 40 Then
          MsgBox "Age must be above 18"
        Else
          MsgBox "Thank You"
        End If
      Else
        MsgBox "Please enter a numeric value"
      End If
    End Sub
    -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <H3>Simple Validation</H3><HR>
    <FORM NAME="ValidForm">
    Enter your age:
    <INPUT NAME="Text1" TYPE="TEXT" SIZE="2">
    <INPUT NAME="Submit" TYPE="BUTTON" VALUE="Submit">
    </FORM>
    </BODY>
    </HTML>

     

    Filed under:
  • 07-10-2011 11:27 AM In reply to

    Re: Help with numeric validation using VBScript

    Why not just use InfoPath's built-in validation features?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.