Jump to content

form validation


Matar

Recommended Posts

hi i am trying to validate html form with asp function , so the problem is how i will know which field is empty ,, this is the i wrote ***dim name name = request.form("name")if name = "" thenresponse.redirect = ("error.asp?name_null")end if ********after the user enter the data its will store in database , so i make an add.asp page thats will requset the data from the form like this :<%dim name name = request.form("name")if name = "" thenresponse.write(" Enter Your Name")end if %><%Dim conn Dim rs Set Conn = Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/webdata/atc.mdb"))set rs = Server.CreateObject("ADODB.recordset") RS.open "reg",Conn,2,2rs.AddNewrs.Fields("Name") = Request.Form("name")rs.Updaters.CloseSet rs = NothingSet Conn = Nothing%>********with this code the user will Know Where is the Error , but if he Enter a correct dataand press submit he will Redirected to add.asp page and he will still um this page so , he will not redircted to the confirmation page . when i make the code like this <%dim name name = request.form("name")if name = "" thenresponse.write(" Enter Your Name")end if %><%Dim conn Dim rs Set Conn = Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/webdata/atc.mdb"))set rs = Server.CreateObject("ADODB.recordset") RS.open "reg",Conn,2,2rs.AddNewrs.Fields("Name") = Request.Form("name")rs.Updaters.CloseSet rs = NothingSet Conn = Nothingresponse.redirct="confirm.asp"%>if the user let the field empty he will redirected To the confirm page and he will think the regesteration is completed . i need a code redircted the user to error page and didcted the empty field .

Link to comment
Share on other sites

hi i am trying to validate html form with asp function , so the problem is how i will know which field is empty ,, this is the i wrote

Is this the thing u required??<%dim name name = request.form("name")if name = "" then response.redirect = ("error.asp?name_null")ElseDim conn Dim rs Set Conn = Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/webdata/atc.mdb"))set rs = Server.CreateObject("ADODB.recordset") RS.open "reg",Conn,2,2rs.AddNewrs.Fields("Name") = Request.Form("name")rs.Updaters.CloseSet rs = NothingSet Conn = Nothingresponse.redirct="confirm.asp"end if %>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...