Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

instr function

Status
Not open for further replies.

crackon

Programmer
Jun 17, 2009
26
Cant understand why this wont work?

if InStr(1,request.form(fieldName),"Yes")= 0 then

I want to look for yes in a form field and retunr error if its not a Yes?
 
Try....

Code:
If Instr(1,[!]Trim([/!]request.form(fieldname)[!])[/!],"Yes"[!], 1[/!]) = 0 Then

By default, InStr is case sensitive (so Yes <> yes). If you use the optional 4th parameter and pass a 1, it will use a case-insensitive compare. Also added the trim just in case there are leading or trailing spaces.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
still no

heres the call
<%if Session("idcustomer")<>0 then%>
<input type="hidden" name="username" value="<%response.write pConfirm %>">
<%else%>
<%
validate "confirm", "required"%><%textbox "confirm", pConfirm, 3, "textbox"%>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">(Agree with the terms and conditions)</font><%
end if%>
</TD>


and heres the alert if not valid

case "confirm"
If Instr(1,Trim(request.form(fieldName)),"Yes", 1) = 0 then
dicError(fieldName) = dictLanguage.Item(Session("language")&"_validateform_11") & "<i>" & fieldName & "</i>"
end if



heres where it checks for having a character

sub textbox(byVal fieldName , byVal fieldValue, byVal fieldSize, byVal fieldType)
dim lastValue
lastValue = request.form(fieldName)

select case fieldType
case "textbox"
%>
<input name="<%=fieldName%>" size="<%=fieldSize%>" value="<%

if trim(fieldValue)<>"" then
response.write fieldValue
else
response.write Server.HTMLEncode(lastValue)
end if%>">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top