For example, for an account application form, enter an account at the time of billing, and the system determines whether the account exists in the system.
1. Write the JavaScript function for judgment in the JS header of the form:
VaR request;
Function checkloginname (){
Request = new activexobject ("msxml2.xmlhttp ")
If (! Request ){
Request = new activexobject ("Microsoft. XMLHTTP ");}
Request. onreadystatechange = aftercheckloginname;
// Assume that the database path is MIS/accounts. nsf, and the input account field in the form is account. The value of this field is passed to the proxy.
Url = "/MIS/accounts. nsf/checkrepeatid? Openagent & id = "+ document. Forms [0]. Account. value;
Request. Open ("Post", URL, true );
Request. Send (null );
}
Function aftercheckloginname (){
If (request. readystate = 4 ){
If (request. Status = 200 ){
If (request. responsetext. indexof ("1")>-1 ){
Alert ("sorry, this account is already in use! ");
Document. Forms [0]. Account. value = "";
Document. Forms [0]. Account. Focus ();
}
}
}
}
2. Create a checkrepeatid Proxy:
Sub initialize
Dim ss as new notessession
Dim doc, docx as notesdocument
Dim view as notesview
Dim dB as notesdatabase
Set Doc = ss. documentcontext
Set DB = ss. currentdatabase
Set view = dB. getview ("checkid") 'is an account attempt.
Macro = | @ rightback (query_string_decoded; "=") | 'gets the parameter passed from the URL.
Id = evaluate (macro, DOC)
Set docx = view. getdocumentbykey (ID (0), true)
Print "Content-Type: text/XML"
If not docx is nothing then
Print "1"
Else
Print "0"
End if
End sub
3. Enter the account domain in the form. For example, the account is used here. In the onchange or onblur event of the domain, the JavaScript method checkloginname () is called ()