Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM vbscript

date posted 23rd January 2003 18:26

Erk! That's never going to run, even if you manage to call it. And
if you do get it to run, it's never going to finish :/

Leaving aside the fact that there are probably more elegant ways to do
this, you have at least the following obvious problems:

1) All of your IF statements are missing closing brackets, e.g.

if Not validnamecontents(Request.Form("Name") Then

should be

If Not validnamecontents(Request.Form("Name")) Then

2) Your while...wend loop will never exit, as you're not incrementing the
counter variable

3) ValidatePostcodeContents appears to have picked up some java/php/C
style { } braces instead of If ... Then ... End if

4) So does ValidatePhoneContents

That's just the stuff on a quick first look through. Really there
are neater ways to code a lot of that, using either an array or a
collection to hold the strings etc. etc. but I have to go cook now or
I'll be divorced :)


--
Pete

==== Original Message:

> It is a bit long but here it is - Thanks Pam


>
> Function valid_form()
> Response.write("bbb")
> Dim Name_Error_msg
> Dim Address_error_msg
> Dim Address1_error_msg
> Dim Town_error_msg
> Dim County_error_msg
> Dim Postcode_error_msg
> Dim HomeTel_error_msg
> Dim Email_error_msg
> Dim Comment_error_msg
> Dim Error_msgs
> Error_msgs = 0

> if Not validnamecontents(Request.Form("Name") Then
> Name_Error_msg = "Please complete a valid Name"
> Error_msgs = Error_msgs + 1
> End if

> if Not validaddresscontents(Request.Form("Address") Then
> Address_error_msg = "Please complete a valid Address"
> Error_msgs = Error_msgs + 1
> End if

> if Not validaddress2contents(Request.Form("Address1") Then
> alert("a")
> Address1_error_msg = "Please complete a valid Address or leave blank"
> Error_msgs = Error_msgs + 1
> End if

> if Not validaddresscontents(Request.Form("Town") Then
> Town_error_msg = "Please complete a valid Town"
> Error_msgs = Error_msgs + 1
> End if

> if Not validaddress2contents(Requst.Form("County") Then
> County_error_msg = "Please complete a valid County")
> Error_msgs = Error_msgs + 1
> End if

> if Not validpostcodecontents(Request.Form("Postcode")
> Postcode_error_msg = "Please complete a valid Postcode"
> Error_msgs = Error_msgs + 1
> End if

> if Not validtelephonecontents(Request.Form("HomeTel")
> HomeTel_error_msg = "Please complete your contact telephone number"
> Error_msgs = Error_msgs + 1
> End if

> //CHECK EMAIL ADDRESS IF NOT BLANK (inputbox)

> Dim inputbox = Request.form("Email")
> if Len(inputbox)!= 0 Then

> // Convert inputbox to string

> Dim teststring

> teststring = CStr(inputbox)

> // Check for at least 7 chrs

> if Len(teststring) Email_error_msg = "The email address you have entered is not a valid
> format"
> Error_msgs = Error_msgs + 1
> End if

> // Check for Illegal Characters

> Dim illegalchrs(5)
> illegalchrs = Array("*","£","$","!")

> Dim counter
> counter = 0
> While counter < 5
> if InStr(0, teststring, illegalchrs[counter]) != 0 Then
> Email_error_msg = "You have entered an invalid character in your email
> address"
> Error_msgs = Error_msgs + 1
> End if
> Wend

> // Check for the @ and the dots

> // First check that they both exist

> Dim atpositionback = InStrRev(teststring, [EMAIL REMOVED]
> Dim dotpositionback = InStrRev(teststring, ".")
> Dim atpositionfront = InStr(teststring, [EMAIL REMOVED]

> if atpositionback = 0 Then
> Email_error_msg = "The email address you have entered is not a valid
> format"
> Error_msgs = Error_msgs + 1
> End if

> if dotpositionback = 0 Then
> Email_error_msg = "The email address you have entered is not a valid
> format"
> Error_msgs = Error_msgs + 1
> End if

> if atpositionfront Not = atpositionback Then
> Email_error_msg = "The email address you have entered is not a valid
> format"
> Error_msgs = Error_msgs + 1
> End if

> if atpositionback > dotpositionback Then
> Email_error_msg = "The email address you have entered is not a valid
> format"
> Error_msgs = Error_msgs + 1
> End if

> End if

> if Not validcommentscontents(Request.Forms("Comments")) Then
> Comment_error_msg = "Please complete a valid comments/enquiries field"
> Error_msgs = Error_msgs + 1
> End if

> if Error_msgs > 0 Then
> valid_form = False
> Else
> valid_form = True
> End if

> End Function

> Function validcommentscontents(inputbox)
> Dim teststring
> teststring = CStr(inputbox)
> teststring = Trim(teststring)
> if teststring = "" Then
> validcommentscontents = False
> Exit Function
> End if
> if IsNumeric(teststring) Then
> validcommentscontents = False
> Exit Function
> End if
> validcommentscontents = True
> End Function

> Function validnamecontents(inputbox)
> Dim teststring
> teststring = CStr(inputbox)
> teststring = Trim(teststring)
> if teststring = "" Then
> validnamecontents = False
> Exit Function
> End if
> if IsNumeric(teststring) Then
> validnamecontents = False
> Exit Function
> End if
> if Len(inputbox) < 2 Then
> validnamecontents = False
> Exit Function
> End if
> validnamecontents = True
> End Function

> Function checkvalidaddresscontents(inputbox)
> Dim teststring
> teststring = CStr(inputbox)
> teststring = Trim(teststring)
> if teststring = "" Then
> checkvalidaddresscontents = False
> Exit Function
> End if
> if IsNumeric(teststring) Then
> checkvalidaddresscontents = False
> Exit Function
> End if
> checkvalidaddresscontents = True
> End Function

> Function validaddress2contents(inputbox)
> Dim teststring
> teststring = CStr(inputbox)
> teststring = Trim(teststrimg)
> if teststring = "" Then
> checkvalidaddresscontents = True
> Exit Function
> End if
> if IsNumeric(teststring) Then
> checkvalidaddresscontents = False
> Exit Function
> End if
> checkvalidaddresscontents = True
> End Function

> Function validpostcodecontents(inputbox)
> Dim teststring
> teststring = CStr(inputbox)
> teststring = Trim(teststring)
> if testString = "" Then
> validpostcodecontents = True
> Exit Function
> End if
> if IsNumeric(teststring) Then
> validpostcodecontents = False
> Exit Function
> End if
> if (Len(teststring) < 2 Or Len(teststring.length) > 8) {
> validpostcodecontents = False
> Exit Function
> }
> validpostcodecontents = True
> End Function

> Function validtelephonecontents(inputbox)
> var teststring
> teststring = CStr(inputbox)
> if Trim(teststring) = "" Then
> validtelephonecontents = True
> Exit Function
> End if
> Dim count = 0
> While count < Len(inputbox)
> Dim c = Mid(inputbox, count, 1)
> if ((c Not = " ") And (c Not = "-") And Not IsNumeric(c)) Then
> validtelephonecontents = False
> Exit Function
> }
> count = count + 1
> Wend
> return 0
> End Function
>


> '

> NTMail K12 - the Mail Server for Education
> ========
> Freelancers and Freelance Jobs: http://www.freelancers.net

> Advertise with Freelancers.net http://www.freelancers.net/advert.php

> To unsubscribe please email: [EMAIL REMOVED]

> If you have difficulties unsubscribing please email: [EMAIL REMOVED]



Messages by Day
January 31st 2003
January 30th 2003
January 29th 2003
January 28th 2003
January 27th 2003
January 26th 2003
January 25th 2003
January 24th 2003
January 23rd 2003
January 22nd 2003
January 21st 2003
January 20th 2003
January 19th 2003
January 18th 2003
January 17th 2003
January 16th 2003
January 15th 2003
January 14th 2003
January 13th 2003
January 12th 2003
January 11th 2003
January 10th 2003
January 9th 2003
January 8th 2003
January 7th 2003
January 6th 2003
January 5th 2003
January 4th 2003
January 3rd 2003
January 2nd 2003
January 1st 2003


Messages by Month
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000