Code:if left(request.Form("phone_nu"),3) = "234" and len(request.Form("phone_nu")) < 11 then response.Redirect("sms.asp?error="&(request.Form("phone_nu"))) end if
| SitePoint Sponsor |





Code:if left(request.Form("phone_nu"),3) = "234" and len(request.Form("phone_nu")) < 11 then response.Redirect("sms.asp?error="&(request.Form("phone_nu"))) end if

Looks fine to me. One possibility is removing the "" from around 234.
"Does this napkin smell like chloroform?"
...now with SnapFoo!
My Blog | My Twitter | My Company | SitePoint Podcast
*** Matt Mullenweg on the SitePoint Podcast ***





One thing which looks slightly strange to me is this part of response.redirect:
I don't know why you should enclose the request.form itself with brackets? If that's correct, could anybody explain the reason to me? Still an asp beginner myself.Code:(request.Form("phone_nu"))
Good point, I didn't even look at the response.redirect line![]()
"Does this napkin smell like chloroform?"
...now with SnapFoo!
My Blog | My Twitter | My Company | SitePoint Podcast
*** Matt Mullenweg on the SitePoint Podcast ***





I really dont think its the 234 or "234"
'cause thats based on int value, not a string.
I dont get an error, it just doesnt work
It works if i leave it as
if len(request.Form("phone_nu")) < 11 then
response.Redirect("sms.asp?error="&(request.Form("phone_nu")))
end if
Did you response.write request.form("phone_nu") just to verify the value? It obviously is not matching to "234" so there is either an extra space in the value, or you are comparing a int to a string.
"Does this napkin smell like chloroform?"
...now with SnapFoo!
My Blog | My Twitter | My Company | SitePoint Podcast
*** Matt Mullenweg on the SitePoint Podcast ***





I keep getting this erro on sitepoints site. Am looking were to report it, 'cause i have to keep refreshing the page





Yes, but thats not the error. It works if i remove the left() functionDid you response.write request.form("phone_nu") just to verify the value? It obviously is not matching to "234" so there is either an extra space in the value, or you are comparing a int to a string.





Have you tried something like this:
Code:strTest = left(request.form("phone_nu"),3) response.write = strTest





Ok
I would test all values in my request object and see what i get
BRB

Do you want to only see the error if the length is less than 11 AND the first three positions are 234? Or do you want to see the error if the length is less than 11 OR if the first three positions are 234? If it's the second case, your code will not work.
If you want option one, try this:
If it's option two you want, try this:Code:Dim strNum strNum = Trim(Request.Form("phone_nu")) if left(strNum, 3) = "234" and len(strNum) < 11 then Response.Redirect("sms.asp?error=" & strNum) end if
Code:Dim strNum strNum = Trim(Request.Form("phone_nu")) if left(strNum, 3) = "234" or len(strNum) < 11 then Response.Redirect("sms.asp?error=" & strNum) end if





sorry, am trembling at your avatar.....
.......signed out of sitepoint





Just joking, pls give me a minute to try it out
Afrika





hi DaveMaxell,
this works very well.Dim strNum
strNum = Trim(Request.Form("phone_nu"))
if left(strNum, 3) = "234" and len(strNum) < 11 then
Response.Redirect("sms.asp?error=" & strNum)
end if
I have tested thoroughly, its ok.
rgds
Afrika





hi
its just called delimiters in programming, whatever you enclose coudl work as a unit, its just makes it neater.Originally posted by c2uk
One thing which looks slightly strange to me is this part of response.redirect:
Code:
(request.Form("phone_nu"))
I don't know why you should enclose the request.form itself with brackets? If that's correct, could anybody explain the reason to me? Still an asp beginner myself.
e.g. in SQL you could use () or '' to enclose a string
hope u do understand





Thanks for the explanation, I think I know what it does now, still it looks strange to me, at least in this context.





many things are strange to me, That a computer can read and understand my script
amazes me
Bookmarks