- Validation of a text field -

Hi there,

Is there a way to validate a text field to have Alpha Numeric values? Example AA12345? So If the user inputs 12345 only, there should be a prompt informing the user to enter Alpha Numberic AA12345. Any assistance is greatly appreciated.

Subject: - Validation of a text field -

Is it a Web or a Client Application. If its a Web application u can use the following Javascript function.

function splchrCheck(src) {

var crt=“ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890”

if (src.indexOf(“.”)!=-1)src=src.substr(0,src.indexOf(“.”));

for (i=0;i<src.length;i++)

{

var chr = src.charAt(i);

chr = chr.toUpperCase()

if (crt.indexOf(chr)==-1)

	{

		return true;

	}

}

return false;

}

Subject: RE: - Validation of a text field -

Hi thanks,

Its a client application, But can this script be used still under input validation? or maybe on an event?

Subject: RE: - Validation of a text field -

try this in input validation:

letters := “A”:“B”:“C”:“D”:“E”:“F”:“G”:“H”:“I”:“J”:“K”:“L”:“M”:“N”:“O”:“P”:“Q”:“R”:“S”:“T”:“U”:“V”:“W”:“X”:“Y”:“Z”;

numbers := “0”:“1”:“2”:“3”:“4”:“5”:“6”:“7”:“8”:“9”;

msg := “Field must contain at least 1 number and 1 letter”;

@If(@Contains(@UpperCase(@Text(Input));letters) & @Contains(Input;numbers);@Success;@Failure(msg))

Subject: RE: - Validation of a text field -

Hi Paul,

Is there a way to validate the input to have 2 letters and then 3 numbers? Instead of validating only if the text field has 1 letter and 1 number?

Subject: RE: - Validation of a text field -

Thanks to all for the information! Greatly Appreciated! :slight_smile:

Subject: RE: - Validation of a text field -

Try the onsubmit.

Shawn

Subject: - Validation of a text field -

I have a code that verify a text field.

In the Exiting propertie of the field i have the follow code:

Sub Exiting(Source As Field)

Dim uiwork As New notesuiworkspace

Dim uidoc As notesuidocument

Dim session As New notessession

Dim db As notesdatabase

Dim doc As notesdocument

Dim docp As NotesDocumentCollection

Dim view As NotesView

Dim cat As String



Set uidoc = uiwork.currentdocument	

Set doc=uidoc.document

Set db = session.CurrentDatabase



Set view=db.GetView("($PDBList)")



cat=doc.PDBNumber(0)



If Len(doc.PDBNumber(0)) <> 7 Then

	' Nº de caracteres inválido

	Messagebox  "The input format for this field is 99999AA", 16, "PDB Validation" 

	Call uidoc.GotoField( "PDBNumber" )

	Continue = False

Else

	For i=1 To 5

		char=Mid(doc.PDBNumber(0),i,1)

		If char <"0" Or char > "9" Then

			Messagebox  "The input format for this field is 99999AA", 16, "PDB Validation" 

			Call uidoc.GotoField( "PDBNumber" )

			Continue = False				

		End If

	Next

	For i=6 To 7

		char=Mid(doc.PDBNumber(0),i,1)

		If char <"A" Or char > "Z" Then

			Messagebox  "The input format for this field is 99999AA", 16, "PDB Validation" 

			Call uidoc.GotoField( "PDBNumber" )

			Continue = False				

		End If

	Next

End If



Set docp = view.GetAllDocumentsByKey (cat)



If docp.count>0 Then

	' Já existe um registo com este número de BDP

	Messagebox  "Already exists a PDB with this number", 16, "PDB Validation" 

	Call uidoc.GotoField( "PDBNumber" )

	Continue = False

End If

End Sub