您好我在本地公司实习,他们希望我编写一个基于Web的应用程序,将数据输入并输入到sql中。我在调用vbscript验证函数时遇到问题。我知道vbscript现在是用于web开发的糟糕语言,但老板只会使用vbscript和visual basic 6来满足任何编程需求。
<form name="EmployeeForm" action= "ATRAddEditEmployeeForm.asp" method="post">
Pin Number <input type="text" name="Pin" value=<% = chr(34) & request.querystring("Pin") & chr(34) %>><br/>
Full Name <input type="text" name="FullName" value=<% = chr(34) & FullName & chr(34) %> /><br/>
PayRoll ID <input type="text" name="PayRoll" value=<% = chr(34) & PayRoll & chr(34) %>> <br/>
<input type="radio" name="Status" Value="Active" <% if Status = "A" then response.write "checked" end if%>/>Active  
<input type="radio" name="Status" Value="Terminate"<% if Status = "T" then response.write "checked" end if%>/>Terminate<br/>
<select>
'I removed all information inside the select simply because it is not needed
</select>
<input type="submit" name = "cmdSubmit" value ="Submit"/>
</form>
function Validate()
if 1 = 2 then
Validate = true
else
Validate = false
end if
msgbox Validate 'the rest of this function is work in progress
response.write "Adc"
' dim SQL
' dim Pin
' dim PayRoll
' dim NumPin
' dim NumPayRoll
' dim FormObject
' dim ErrorReason
' on error resume next
' set FormObject = document.forms("EmployeeForm")
' Pin = FormObject.Pin.Value
' PayRoll = FormObject.PayRoll.Value
' ErrorReason=""
' if connect(1) then
' SQL = "SELECT count(Pin) as NumPin from ISO_Employee where pin = " & Pin
' if query(rs, sql) then
' do until rs.eof
' NumPin = dbf(rs,"NumPin")
' rs.movenext
' loop
' rs.close
' else
' response.write ErrDesc
' end if
' SQL = "SELECT count(payrollid) as payroll from ISO_Employee where payrollid = " & PayRoll
' if query(rs,sql) then
' do until rs.eof
' NumPayRoll = dbf(rs,"NumPayroll")
' rs.movenext
' loop
' else
' response.write ErrDesc
' end if
' if NumPin <> 0 then
' ErrorReason ="Not a unique Pin Number"
' end if
' if NumPayRoll <> 0 then
' ErrorReason = ErrorReason & "Not a unique Pin Number"
' end if
' disconnect
' else
' response.write ErrDesc
' end if
' if ErrorReason <> "" then
' 'show why validate failed
' Validate = false
' else
' Validate = true
' end if
end function
sub cmdSubmit_onClick
If Validate() then
document.EmployeeForm.submit
else
response.write "Failed"
end if
end sub
应该注意,html代码位于与validate函数和onsubmit函数不同的文件中。 validate和onsumbit函数位于全局.asp文件中,该文件包含在本网站的所有其他页面中 这应该始终返回false,但它仍然发布表单。有没有人有任何想法,或者我应该在服务器端进行所有验证,如果验证是假的,只需重新加载页面?
答案 0 :(得分:0)
最初的问题是1永远不会等于2.你不能使用整数作为变量。
if **1 = 2** then
Validate = true
else
Validate = false
end if