Validating forms using vbscript
In JAVA Net Beans Text() method is used to extract the text from the text fields.
Hi I'm interning at a local business and they want me to write a web based application that will take data in and input it into sql.
I'm having trouble with calling the vbscript validate function. Value ' Error Reason="" ' if connect(1) then ' SQL = "SELECT count(Pin) as Num Pin from ISO_Employee where pin = " & Pin ' if query(rs, sql) then ' do until ' Num Pin = dbf(rs,"Num Pin") ' rs.movenext ' loop ' rs.close ' else ' response.write Err Desc ' end if ' SQL = "SELECT count(payrollid) as payroll from ISO_Employee where payrollid = " & Pay Roll ' if query(rs,sql) then ' do until ' Num Pay Roll = dbf(rs,"Num Payroll") ' rs.movenext ' loop ' else ' response.write Err Desc ' end if ' if Num Pin "" then ' 'show why validate failed ' Validate = false ' else ' Validate = true ' end if end function sub cmd Submit_on Click If Validate() then document.
I know that vbscript is a poor language to use for web dev nowadays but the boss will only use vbscript and visual basic 6 for any programming needs. Employee Form.submit else response.write "Failed" end if end sub It should be noted that the html code is located in a different file than the validate function and the onsubmit function.
In the given example we just write a message saying the all went well, however that part is where we should insert our main code which might be an insert command, an email forwarding or whatever you like.
The checks we've developed with the above code are very simple.
What makes the above snippet incredibly flexible is the fact that we can insert specific validation checks on every single field, giving us a wider customization.There are tons of ready-made form validation functions on the web, especially written in Java Script, however sometimes we might need to do something a little bit more customized.Here I will explain the basic concept behind a form validation using VBScript in an ASP page. In our example, we are going to use a form with only two input fields: a user name and an email.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 Pay Roll ' dim Num Pin ' dim Num Pay Roll ' dim Form Object ' dim Error Reason ' on error resume next ' set Form Object = document.forms("Employee Form") ' Pin = Form Object. The validate and onsumbit function are located in a global file that is included in all other pages of this website This should always return a false however it is still posting the form.Does anyone have any idea, or should I do all the validation on the server side and just reload the page if the validation is false?