Ajax + ASP application instance registration module, form submission

Source: Internet
Author: User

<! -- Register the module --> default. asp CopyCode The Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> Ajax-sample1 </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> // be sure to encode this page as a UTF-8, otherwise, garbled characters will appear.
<Meta name = "author" content = "tonyhl [at] 126.com"/>
<Meta http-equiv = "Pragma" content = "no-Cache"/>
<Script language = "JavaScript" type = "text/JavaScript" src = "Reg. js"> </SCRIPT>
<LINK rel = "stylesheet" href = "css.css" type = "text/CSS" Media = "all"/>
<Style type = "text/CSS">
<! --
# Layer1 {
Position: absolute;
Width: 200px;
Height: 115px;
Z-index: 1;
Left: 409px;
Top: 88px;
}
-->
</Style>
</Head>
<Body>
<H2> Ajax application instance: Registration Module </H2>
<Div id = "layer1">
<Div id = "MSG"> </div>
</Div>
ID: <input type = "text" id = "regid"/>
Password: <input type = "password" id = "regpassword"/>
<Input name = "F" type = "file"/>
<Input type = "Submit" id = "regsubmit" value = "register" onclick = "check ()"/>
<H2> when a user with a registered ID of Tony is registered, the background verifies that the ID already exists and returns a prompt message. <br/>
To highlight the refreshing effect, the server side Program Millions of addition operations will be performed automatically
</H2>
</Body>
</Html>

copy the Code the code is as follows: Reg. JS
function Ge (a) {return document. getelementbyid (a) ;}< br> Function check () {
If (Ge ('regid '). value = '') {Ge ('msg '). innerhtml = 'id cannot be blank '; return false}
If (Ge ('regpassword '). value = '') {Ge ('msg '). innerhtml = 'password cannot be blank '; return false}
var x = new activexobject ("msxml2.xmlhttp");
If (X) {
Ge ('regsubmit '). disabled = true;
X. onreadystatechange = function () {
If (X. readystate = 4) {
If (X. status = 200) {
eval (X. responsetext)
}< br> else {Ge ('msg '). innerhtml = x. statustext }< BR >}< br> else {Ge ('msg '). innerhtml = "submitting data... "}
};
X. open ('post', 'reg. ASP ', true);
X. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded');
var senddata = 'regid = '+ ge ('regid '). value + '& regpassword =' + ge ('regpassword '). value + '& file =' + ge ('F '). value
X. send (senddata)
}< br> else {
Ge ('msg '). innerhtml = 'your browser does not support XMLHttpRequest '
}< BR >}

Reg. ASP copy Code the code is as follows: <% @ Language = "VBScript" codePage = "65001" %> // codePage must be 650001; otherwise, garbled characters may also appear. If there is HTML text, it must be set to UTF-8 encoding, otherwise, garbled characters will appear.
<%
dim regid, regpassword, STR
regid = request. form ("regid")
regpassword = request. form ("regpassword")
F = request. form ("file")
dim I, II
II = 0
for I = 0 to 1000000
II = II + I
next
If regid = "" Or regpassword =" "Then
STR =" ID and password are required "
else
If regid <>" Tony "then
STR =" registration successful, the ID is "& regid &", the password is "& regpassword & F
else
STR =" registration failed, the ID already exists "
end if
response. write "Ge ('msg '). innerhtml = '"& STR &"'; GE ('regsubmit '). disabled = false "
response. end
%>

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.