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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit form

Status
Not open for further replies.

boux123

Technical User
Mar 20, 2007
16
0
0
CA
Hi,

I am creating this condition where once a user clicks the submit button, the form is checked to see if there are any blank fields, if there are any blank fields, then the user is prompted to refilled the form. However, if there are no blank fields, then the form is successfully submitted. I am mainly using vbscript so I would like to stick to that code. However, I really havent found any code that makes fields mandatory. So i decided to use logic. The problem is, when i purposely leave a blank field ans send the form, the form is being submitted successfully. Please advise.

"

sub CheckFields()

Dim strList,packageType, action, distDate, distTime, packageName, CreationTime


'put the list of servers selected into a string varialbe.
'store each of the form input fields into separate variables
packageName = Request.QueryString("packageName")
packageType = Request("packageType")
action = Request("actionRequested")
distDate = Request.QueryString("dateTextField")
distTime = Request.QueryString("time")
strList = Request.Form("server")



'dont submit a request if there are no servers checked, and if the mandatory fields are empty.
if Request.Form("requestSubmit") Then

If (packageName = "" OR packageType = "" OR action = "" OR distDate = "" OR distTime = "" OR strList = "") Then

MsgBox "Required fields have not yet been completed."
'Response.Write "<center>" & "<b>" & "Required fields have not yet been completed." & "</b>" & "</center>"


Else

'grab the string of servers selected, parse them out and load them into the database.
list = Replace(strList, "/", "")
list = Replace(list, " ", "")

Response.Write "<center>" & "<b>" & list & "</b>" & "</center>"

'Update the database with the entry
oConn.Open(ConnectionString)
queryStr = "INSERT INTO tblPDRitem ( pdrItemCreationTime, packageName, packageType, actionRequested, distributionDate, distributionTime, distributionServers) VALUES( getDate() ,'" & TRIM(Request.QueryString("packageName")) & "', '" & TRIM(Request.QueryString("packageType")) & "','" & TRIM(Request.QueryString("actionRequested")) & "','" & Request.QueryString("dateTextField") & "','" & Request.QueryString("time") & "','" & TRIM(list) & "')"
Set oRsSub = oConn.Execute(queryStr)

oConn.Close


End if
End if
End Sub

Thx
 
This should be done client side because for you to be able to check the information from the form server side, that form HAD to have already been submitted.

I am creating this condition where once a user clicks the submit button

ans send the form, the form is being submitted successfully



[monkey][snake] <.
 
Ye i realized that:

Here is what I did:

"
<script language="vbscript">

dim validation

Function newRequestForm_OnSubmit

validation = True



Dim strList,packageType, action, distDate, distTime, packageName, CreationTime


'put the list of servers selected into a string varialbe.
'store each of the form input fields into separate variables
packageName = Request.QueryString("packageName")
packageType = Request("packageType")
action = Request("actionRequested")
distDate = Request.QueryString("dateTextField")
distTime = Request.QueryString("time")
strList = Request.QueryString("server")



'dont submit a request if there are no servers checked, and if the mandatory fields are empty.
'if Request.Form("requestSubmit") Then

'If (packageName = "" OR packageType = "" OR action = "" OR distDate = "" OR distTime = "" OR strList = "") Then
If packageName = "" Or packageType = "" Or action = "" Or distDate = "" Or distTime = "" Or strList = "" Then

'Response.Write "Required fields have not yet been completed."
Response.Write "<center> <b> Required fields have not yet been completed.</b></center>"

'Response.Write packageName + "," + packageType + "," + action + "," + distDate + "," + strList + "," + distTime
validation = False;

Else
Response.Write "<center><b> Form has been submitted </b> </center>"

'grab the string of servers selected, parse them out and load them into the database.
list = Replace(strList, "/", "")
list = Replace(list, " ", "")

'Response.Write "<center>" & "<b>" & list & "</b>" & "</center>"

'Update the database with the entry
oConn.Open(ConnectionString)
queryStr = "INSERT INTO tblPDRitem ( pdrItemCreationTime, packageName, packageType, actionRequested, distributionDate, distributionTime, distributionServers) VALUES( getDate() ,'" & TRIM(Request.QueryString("packageName")) & "', '" & TRIM(Request.QueryString("packageType")) & "','" & TRIM(Request.QueryString("actionRequested")) & "','" & Request.QueryString("dateTextField") & "','" & Request.QueryString("time") & "','" & TRIM(list) & "')"
Set oRsSub = oConn.Execute(queryStr)

oConn.Close


End if

if validation = True Then

newRequestForm_OnSubmit = True

Else

newRequestForm_OnSubmit = False

End if

End Function


</script>

"

I still get error boxes. And when submit empty forms, the request is being processed successfully. Is there anything wrong with my syntax. Please advise

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top