Validate a Field

Hi,

I have 2 fields.

For the first field i have to validate such as first character is a letter and the 6 characters after that are numbers.

For the second field, the field should contain ten digits and the first digit should not be “0”.

I have to do this using Lotus Script.

Can anyone help me on this.

Thanks in advance

Subject: Validate a Field

try something like this…

jason

jasonsmith@columbusga.org

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’

'check for field 1

If Len(doc.field1(0)) = 7 Then

field1A$ = Left$(doc.field1(0), 1)

field1B$ = Right$(doc.field1(0), 6)

If Not field1A$ Like "[A-Z]" And Not field1B$ Like "[0-9][0-9][0-9][0-9][0-9][0-9]" Then

	Msgbox "Field 1 must contain an A-Z as the first character and 0-9 as the next 6 characters.", 48, "Incorrect Value!"

End If

Else

	Msgbox "Field 1 must contain 7 characters.", 48, "Incorrect Value!"

End If

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’

'check for field 2

If Len(doc.field2(0)) = 10 Then

field2A$ = Left$(doc.field2(0), 1)

field2B$ = Right$(doc.field2(0), 9)

If field2A$ = "0" And Not field2A$ Like "[0-9]" And Not field2B$ Like "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" Then

	Msgbox "Field 2 must contain 10 characters and may not contain 0 as the first character.", 48, "Incorrect Value!"

End If

Else

	Msgbox "Field 2 must contain 10 characters.", 48, "Incorrect Value!"

End If

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’

Subject: Validate a Field

For the first field i have to validate such as first character is a letter and the 6 characters after that are numbers.

It sounds like there are two conditions to check - the length and the pattern. This should work:

Const FLD01_LENGTH = 7

Const FLD01_PATTERN = “[a-zA-Z][0-9][0-9][0-9][0-9][0-9][0-9]”

Dim strVal As String

'// assuming that “doc” has is already set to the NotesDocument

strVal$ = trim$(doc.GetItemValue(“Field01”)(0))

select case true

case len(strVal$) < FLD01_LENGTH, not(strVal$ like FLD01_PATTERN)

msgbox {The value of the “Field01” field is invalid - please try again.}, , “Invalid field value . . .”

end select

For the second field, the field should contain ten digits and the first digit should not be “0”.

So you just have a minimum value then, right? If so, then this should work:

Const MIN_VALU& = 1000000000&

dim varTmpVal as variant

'// assuming that “doc” has is already set to the NotesDocument

varTmpVal = doc.GetItemValue(“Field02”)(0)

select case true

case not(isnumeric(varTmpVal)), val(varTmpVal) < MIN_VALU

msgbox {The value of the “Field02” field is invalid - please try again.}, , “Invalid field value . . .”

end select