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
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