943,553 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 2984
  • ASP RSS
May 22nd, 2008
0

Validation vbscript to ASP

Expand Post »
Im having problems with getting the page to stop progressing to the asp one when the user enters the text outwith the limits i.e. no data entered. Could anyone give any guidance?

Cheers

html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title></title>
  4.  
  5. <SCRIPT LANGUAGE="VBScript">
  6. dim validation
  7.  
  8.  
  9. Function MyForm_OnSubmit
  10. validation = False
  11.  
  12.  
  13. MyForm_OnSubmit = False
  14. If (Len(Document.MyForm.txtSurName.Value) > 12) Then
  15. MsgBox "You have entered more than 12 characters"
  16. validation = False
  17. End If
  18. If ((Document.MyForm.txtSurName.Value) = "") Then
  19. MsgBox "You have forgotten to fill in the input box"
  20. validation = False
  21. End If
  22. If (Len(Document.MyForm.txtSurName.Value) < 13) Then
  23. validation = True
  24. End If
  25. If (validation = True) Then
  26. MyForm_OnSubmit = True
  27. Else
  28. MyForm_OnSubmit = False
  29. End If
  30.  
  31. End Function
  32.  
  33.  
  34. </SCRIPT>
  35. </head>
  36. <body bgcolor = "lmonchiffon">
  37. <form name = "MyForm" action = "Validate.asp" method = "post" OnSubmit = "return validate(MyForm_OnSubmit)">
  38. <p>Enter Name</p>
  39. <input type = "text" name = "txtSurName" value = "">
  40. <input type = "submit" value = "Process">
  41. <input type = "reset" value = "reset">
  42. </form>
  43. </body>
  44. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
Run.[it] is offline Offline
57 posts
since Jun 2007
May 23rd, 2008
0

Re: Validation vbscript to ASP

value = "" needed to be initialised and the onSubmit isnt needed and it works a treat.

#
validation = True also needed at the start instead of False.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
Run.[it] is offline Offline
57 posts
since Jun 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: ADODB.Field error '80020009'
Next Thread in ASP Forum Timeline: ASP Session Problem on IIS6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC