|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > an array problem? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|