A simple example of using Ajax in Domino to determine whether an account exists

Source: Internet
Author: User

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 ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.