Subject: How to validade an attachment in a doc before we save it!!!
Try this (Notes Client). I used a regular RTF field, but it should work for RTF Lite as well.Sub Querysave(Source As Notesuidocument, Continue As Variant)
'Validate the rtf field here
Dim doc As NotesDocument
Set doc = source.Document
If(Not validateRTF(source, "rtfAttachments")) Then
If (Not source.Document.HasEmbedded) Then
valid = False
Else
valid = True
End If
Else
valid = True
End If
If valid Then
continue = True
Else
continue = False
Msgbox "There was an error validating the attachment field. Make sure you have attached a file"
End If
If continue Then
doc.saveoptions = "1"
Else
doc.saveoptions = "0"
End If
End Sub
Function validateRTF(source As notesuidocument, rtfName As String) As Boolean
On Error Goto ErrSub
Call source.GoToField(rtfName)
Call source.SelectAll
Call source.copy
Call source.DeselectAll
Goto OkExit
'This error number will be generated when you
'try to copy the content of the empty field
ErrSub:
If Err = 4407 Then
'Check to see if the object is embedded in the form. if not return false
validateRTF=False
'Msgbox "Please enter values for the body field",48,"Error"
Exit Function
End If
Resume OkExit
OkExit:
validateRTF = True
End Function
…and this on the web. Of course a loop would be optimal here, but overkill for what I needed.
//only validate your upload if there are no attachments already… 3 is the # of upload controls used:
if ( numOfAttachments == 0 || (numOfAttachments ==1 && frm.elements[frm.elements.length-1].checked)) {
if ( frm.upload1.value == '' && frm.upload2.value == '' && frm.upload3.value == '' ) {
link = "<a href=\"JavaScript: document." + frm.name + "." + "upload1" + ".focus();\">Go</a> ";
//I use messageArray to store all of my error messages and write them to a div.;
messageArray[x] = link + "You must add at least one attachment to the document.";
frm.upload1.focus();
x++
}
}
numOfAttachments is defined in the HTML HEADER
“<script type="text/javascript">”+@NewLine+
" var numOfAttachments = " + @Text(@Attachments) + “;”+@NewLine +
“”