ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 26th, 2003, 06:40 PM
Hatter Hatter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 Hatter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
an array problem?

Hello

I am experiencing a problem with the message field of a form, and suspect it may be array related.

If I type in a random message - or deliberately leave the message field blank - the form tell me (highlighted in red), that I have an error with the message field.

I am pasting the relevant parts of the code here, in the hope somebody can throw some light on what doesn't look right:

<%DIM ErrorMsg, fullname,email,city,telephone,message%>
<%
const numFields = 5
dim errorArray()
redim preserve errorArray(numFields)

if request.form("isSubmitted") = "yes" then
fullname = request.form("fullname")
city = request.form("city")
telephone = request.form("telephone")
email = request.form("email")
message = request.form("message")


ErrorMsg = ""
dim re
set re = New RegExp

'Message
errorArray(4) = re.Test(message)
if errorArray(4) then
errorArray(4) = False
else
errorArray(4) = True
ErrorMsg = ErrorMsg & "Message<br>"
end if


end if


-------------

'message
<tr><td><% if errorArray(4) = True then %>
<font color="red"><b>
<% end if %>
<% if errorArray(4) = True then %>
</b></font>
<% end if %></td></tr>

<tr>


<textarea class="txt" name="message" value="<%=message%>" rows="5" cols="19"></textarea>



<%
DIM all,i
all=False
For i=0 to 4
all=all OR CBOOL(errorArray(i))
Next
If Not all Then

fullname = request.form("fullname")
email = request.form("email")%>
city = request.form("city")
telephone = request.form("telephone")
message = request.form("message")%>

<%

Any help would be appreciated!

Thanks

Hatter

Reply With Quote
  #2  
Old August 26th, 2003, 07:22 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
Code:
dim re 
set re = New RegExp 

'Message 
errorArray(4) = re.Test(message)

in the re.Test(message) what are you testing message against?
__________________
Programmer's Corner

Reply With Quote
  #3  
Old August 26th, 2003, 11:53 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
in otherwords you need to set the pattern you're searching for
Code:
dim re 
set re = New RegExp 

re.pattern = "reg expression here"
errorArray = re.Test(message)


Test just returns true or false though. Not sure what's with the (4) in your code. Are you searching for the index of where the reg exp matches for the fifth time? You'll need to use re.matches(string) and THEN it's an array

You could also probably be meaning to use these methods as well
Code:
re.Global = True
re.IgnoreCase = True


hope this helps.

Reply With Quote
  #4  
Old August 27th, 2003, 07:57 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Also, your subject title is unacceptable. You can refer to the sticky thread at the top of this forum for more information on how to post a question.

Reply With Quote
  #5  
Old August 27th, 2003, 04:22 PM
Hatter Hatter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 Hatter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello All

Many thanks for your considered replies.

I think I understand what you are referring to:

Unatratnag refers to

re.Global = True
re.IgnoreCase = True

as script I might wish to include in 'Message.

In the name field I already have:

re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
errorArray(0) = re.Test(fullname)
if errorArray(0) then
errorArray(0)=False
else
errorArray(0) = True
ErrorMsg = "Full Name<br>"
end if

but didn't post it because it seems to be only 'Message which is causing me the error. But yes, I can include it in 'Message like this:

re.pattern = "reg expression here"
re.Global = True
re.IgnoreCase = True
errorArray(4) = re.Test(message)
if errorArray(4) then
errorArray(4) = False
else
errorArray(4) = True
ErrorMsg = ErrorMsg & "Message<br>"
end if


I am beginning to think it the re.pattern in 'Message which is giving me the error.

Basically, I want the visitor to be able to write whatever message he wants - however long he wants.

There is another query I have. At the top of my page, where I declare the variables, I have the following (as I indicated in my original posting):

<%DIM ErrorMsg, fullname,email,city,telephone,message%>
<%
const numFields = 5
dim errorArray()
redim preserve errorArray(numFields)

I believe that arrays begin with 0 (as oposed to 1), so would my naming of the message variable as array 4 be causing me the problem?

Thanks for all your help again, much appreciated.

hatter

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > an array problem?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway