Hii Rupen !!
sure i will try to explain it
suppose that u have a login form (say login.asp ),when user enters the form details(like first name,last name,age,location,password,username).It check whether username is already created by different user<-this requires database check.
If the userName is already exists then you want to give alert for username already exists.
this time you dont want to lost all the details of (name,age,location)
*******login.asp page**********
<script>
var jsVariable; //this hold whether the form is alerady posted or not
jsVariable=0;
function callCheck()
{
if(jsVariable==1)
{
alert("UserName is already Existed");
//if you want to clear the usrname text box value then uncomment below line
// document.myform.username.value=" ";
document.myform.username.select();
document.myform.username.focus();
}
}
</script>
<% if request("isposted")="1" then
//database checkup for userid already exists ,here is ur sql stmt,recordset check on dB part
//if dB part is success then set value of databasecheckup="success"
if(databasecheckup=="success") then
//store the username in session
//move to the next page ,which is basicall after the userid has been created
//you can use server.transfer, response.redirect as per your requirement
end if
end if%>
<body onload="callCheck()">
<form name="myform" action="login.asp" method=post>
UserName<input type="text" name="username" value='<%=request("username")%>' > <br>
FirstName<input type="text" name="firstname" value='<%=request("firstname")%>' > <br>
LastName<input type="text" name="lastname" value='<%=request("lastname")%>' > <br>
Address<input type="text" name="address" value='<%=request("address")%>' > <br>
<input type=hidden name="isposted" value="1">
</form>
<%
if reqest("isposted")="1" and databasecheckup<>"success" then
%>
<script>
jsVariable=1;
</script>
<%
end if
%>
</body>
hope this will help you .
Cheers :)
vinod
|