Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I run client/server validation in one event

Status
Not open for further replies.
Feb 8, 2002
43
US
Once I do the function from the submit onclick I have no way of telling the server to run the server code, the sever thinks it is done. Issue: How do I run the server code after I execute my validation function?

Can I make the code to where I can run both the client side and server side code on an onclick event?


<%@ Language = &quot;VBScript&quot;%>
<%
Public Valid
valid = false
%>
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>

<TITLE>AIR</TITLE>
<SCRIPT LANGUAGE=VBscript>
<!--option explicit
function Validate()

dim Logon
dim Flag
valid = false
Flag = false
Logon = document.AIR1.txtLogonID.value
Password = document.AIR1.txtPassword.value
if Logon = &quot;&quot; then
msgbox &quot;Enter in Your Logon ID&quot;,,&quot;No Logon ID&quot;
else
if Isnumeric(Logon) then
msgbox &quot;There must me alpha characters in your Logon ID&quot;,,&quot;Invalid Data&quot;
else
if password = &quot;&quot; then
msgbox &quot;No Password was Entered&quot;,,&quot;Need Password&quot;
else
flag = true
valid = true
end if
end if
end if

end function
-->
</SCRIPT>
</HEAD>
<BODY bgColor=silver>
<FORM METHOD=&quot;post&quot; NAME=&quot;AIR1&quot;>
<p> </p>
<strong><u>AIR</u></strong>
<P>
Logon ID: <INPUT NAME=&quot;LogonID&quot; id=txtLogonID><br>
Password: <INPUT NAME=&quot;Password&quot; id=txtPassword> </P>

<P id=frmAIR> <br> </P>
<input id =cmdSubmit type=submit value=submit name=button1 onclick = validate()>
</FORM>

<%
if valid = true then
'Declaring variables
'Opening and connecting to data
dim conn
dim rs
dim strID
dim strconn

'set a local variable to my DSN-less connection String
strconn = &quot;DRIVER=Microsoft Access Driver (*.mdb);DBQ=&quot; & Server.MapPath(&quot;TPL.mdb&quot;)

'Create the Connection object
set conn = server.createobject(&quot;adodb.connection&quot;)
conn.open strconn

'Create the recordset object
set rs = server.createobject(&quot;adodb.recordset&quot;)
'This statement opens the table so we can add a record notice the addnew
'The 2, 2 is how the table is opened there are many ways it can be opened
rs.open &quot;Logon&quot;, conn, 2, 2

'Use the addnew method of the recordset object to add a record
rs.addnew
'Set the table column = to my input text box from my form
rs(&quot;LogonID&quot;) = request(&quot;LogonID&quot;)
rs(&quot;Password&quot;) = request(&quot;Password&quot;)
rs.update
'I do a movelast here to get the ID that is automatically generated
'I also set the value to a local variable so I can write out to the database
rs.movelast
end if
%>







<%

'Always! Always set your objects to nothing. This clears them out of servers memory
'Your network admins will like this

set rs= nothing
set conn = nothing
%>

</BODY>
</html>
 
add a form.submit() to the function if all the criteria is met to force the form to submit and activate the server code.

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top