Jump to content

validation


knowledgehungry

Recommended Posts

hello, i have phone number as a primary key in my database table. i want to compare the value entered by the user in the textbox which is taken on my asp page with the value of phone number which is in my database, so that the user can get alert that particular phone number is already in the table and user cant move to next page unless and until he enter the phone number different than in table. :) HOW CAN I DO THIS BY USING JAVASCRIPT AND ASP.

Link to comment
Share on other sites

Look up the number in the database:

your_recordset.open("SELECT phone_number FROM the_user_table WHERE phone_number=" & Request.Form("phone_number"))if not your_recordset.eof then  'number existselse  'number does not existend ifyour_recordset.close()

Link to comment
Share on other sites

Look up the number in the database:
your_recordset.open("SELECT phone_number FROM the_user_table WHERE phone_number=" & Request.Form("phone_number"))if not your_recordset.eof then  'number existselse  'number does not existend ifyour_recordset.close()

WHEN I M IMPLEMENTING THE CODE U HAVE WRITTEN I GET FOLLOWING ERROR:ERROR:=========================================Object doesn't support this property or method: 'request.form1' ===========================================
Link to comment
Share on other sites

WHEN I M IMPLEMENTING THE CODE U HAVE WRITTEN I GET FOLLOWING ERROR:ERROR:=========================================Object doesn't support this property or method: 'request.form1' ===========================================
MY CODE LOOK LIKE THISset con = Server.createobject("Adodb.connection")set rs = Server.createobject("Adodb.Recordset")con.connectionstring = somethingcon.open phone1= request.form("TXTPHONE") rs.open("select phone from quality_training where Phone="& phone1 &""),con,3,1 if not rs.eof then Response.Write"<b>This number already exist.<b>" ' rs.close sql,con else rs.open sql,con end ifAFTER IMPLEMENTING UR CODE ITS WORKING FINE BUT AS U CAN SEE THT IN ELSE PART I WANT TO INSERT THE DATA IF THE PHONE NUBER IS NOT SIMILAR TO THT IN TABLE. BUT WHEN M RUNNING THIS CODE IT GIVES ERROR LIKE THISERROR:============================================Operation is not allowed when the object is open. ===========================================
Link to comment
Share on other sites

MY CODE LOOK LIKE THISset con = Server.createobject("Adodb.connection")set rs = Server.createobject("Adodb.Recordset")con.connectionstring = somethingcon.open phone1= request.form("TXTPHONE") rs.open("select phone from quality_training where Phone="& phone1 &""),con,3,1 if not rs.eof then Response.Write"<b>This number already exist.<b>" ' rs.close sql,con else rs.open sql,con end ifAFTER IMPLEMENTING UR CODE ITS WORKING FINE BUT AS U CAN SEE THT IN ELSE PART I WANT TO INSERT THE DATA IF THE PHONE NUBER IS NOT SIMILAR TO THT IN TABLE. BUT WHEN M RUNNING THIS CODE IT GIVES ERROR LIKE THISERROR:============================================Operation is not allowed when the object is open. ===========================================
Link to comment
Share on other sites

You need to close the recordset before you open it again.
else  rs.close()  rs.open sql,conend if

ur genious , THanks a lot But still this is not the proper solution logically i m getting this msg in the next page that the number already exist. i want tht validation on the same page as soon as user enter the phone number and clicks on nextpage button. i know this can be done through javascript and ASP but how to impletement is still a question to me????????
Link to comment
Share on other sites

If you don't want the page to refresh at all, but you still want to check in the database, then you will need to use AJAX to send the request and read the response back, and then do whatever is appropriate on the page. AJAX is a large topic, so if you want to learn how to use AJAX the best place to start is with a Google search.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...