How can I validate the text field?

if fulltrim(doc. text(0)) = “” then Msgbox “please input text”

end if

or

sText = uidoc.FieldGetText(“text”)

If sText = “” Then

Msgbox “please input text”

end if

I tried to validate the text field to see if the field is empty. If it is empty, I will get a popup msg asking me to input text. However, if first line is blank and 2nd line is also blank, then the field is validated without problem. Any idea on how to validate the field if first or multiple lines are empty?

Subject: RE: How can I validate the text field?

I could believe the second test will work as you describe, since of course a field containing a newline character is not equal to the empty string. But the first example should work. Fulltrim definitely removes newlines at the beginning and end. I see this is not the exact code you are using, copied and pasted into your post, so perhaps there is some difference that is causing the problem.

Oh, and of course if there’s a problem you have to do more than print an error message – you have to do something to abort whatever they’re trying to do.

Subject: RE: How can I validate the text field?

Fulltrim only remove blank in the first line…but will not remove blank in next line.

Subject: RE: How can I validate the text field?

Run this script – what is its output? I get len(r) = 0.

Sub Click(Source As Button)

t = {

}

r = Fulltrim(t)

Print "len(r) = " & Len(r)

End Sub

Subject: How can I validate the text field?

I normally put an @Trim( ) in the Input translation to try and remove blanks. But AFAIR, there is still a problem with CR and Line feeds. If so let me know, as I think I had some code that stripped the CR/LF I can try and dig up. Someone else may post a solution sooner.

Is the field a multple value field or a single value field?

Subject: RE: How can I validate the text field?

It is a single value field.

Subject: RE: How can I validate the text field?

I haven’t found the code but I think I did something like this, still digging.

@trim( @ReplaceSubstring( YourVariable ; @NewLine ; “” )