|
| |
|
|
crosscreek
Posts: 107 Joined: 2/5/2008 Status: offline
|
text box meeting a certain criteria - 6/7/2008 23:05:25
I have text box on a form page. The information of the text box is inserted into a database. I want a certain criteria met on the text box information before updating the database fields & not quite sure how to accomplish this. The information in the text box must contain alpha characters & numbers Example: "CNM1254" is accessible, But NOT "CNM " because is must contain numbers. Now the numbers can be any amount CNM025 or CNM25698, etc. Is there a numeric character symbol in ASP? (I can do this with a query, but want give a response.write if the "format" is not correct before updating the query)
|
|
|
|
BeTheBall
Posts: 6381 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: text box meeting a certain criteria - 6/7/2008 23:17:35
Is the numeric always at the end? If so, you could use the Right function to look at the last character. For example: <% If IsNumeric(Right(Request.Form("FieldName"),1))=false Then Response.write "Your Message" else 'Insert code End if %>
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
crosscreek
Posts: 107 Joined: 2/5/2008 Status: offline
|
RE: text box meeting a certain criteria - 6/8/2008 12:17:22
Not always. This is what the text box information should look like LR-CNM07-440-F-PI (Clear) OR LR-CNM07-440-F-PI There are certain Criteria however. F (could be F or M) PI (Could be NOPI, PI, or PIV) My goal is to STOP people from just entering "clear" without a number. Would MID work just as you used? <% If IsNumeric(MID(Request.Form("FieldName"),1))=false Then Response.write "Your Message" else 'Insert code End if %> Thanks for any help!!
|
|
|
|
DesiMcK
Posts: 446 Joined: 4/26/2004 From: Essex, UK Status: offline
|
RE: text box meeting a certain criteria - 6/8/2008 13:24:16
This is probably not a great way to do it but I think it will work. find0=InStr(1, str, "0") find1=InStr(1, str, "1") find2=InStr(1, str, "2") find3=InStr(1, str, "3") find4=InStr(1, str, "4") find5=InStr(1, str, "5") find6=InStr(1, str, "6") find7=InStr(1, str, "7") find8=InStr(1, str, "8") find9=InStr(1, str, "9") mycount = cint(find0+find1+find2+find3+find4+find5+find6+find7+find8+find9) if mycount = 0 then not acceptable else acceptable end if Hope this helps, Desi
|
|
|
|
DesiMcK
Posts: 446 Joined: 4/26/2004 From: Essex, UK Status: offline
|
RE: text box meeting a certain criteria - 6/8/2008 14:40:37
Actually this may be better mycount=0 for i = 0 to 9 mycount=mycount + Cint(InStr(1, str, i)) next if mycount = 0 then not acceptable else acceptable end if
|
|
|
|
crosscreek
Posts: 107 Joined: 2/5/2008 Status: offline
|
RE: text box meeting a certain criteria - 6/8/2008 19:30:39
I will try it as well. (It might be more code friendly or less code to write) Thanks so much. I did get the following to work: cnm2 = LCase(Trim(Replace(request.form("cnm"),"'","''"))) cnm4 = Left(cnm2,10) If CNM2<>"" AND (CNM2 = "clear by parentage" OR CNM2 = "clear by parantage" or CNM2 = "cbp" or CNM2 = "clear" OR IsNumeric(Right(cnm4,1))=false) then cnm1 = request.form("cnm") Response.write "This CNM result ("&cnm1&")is not Acceptable please go back & enter in an acutal CNM clearance number or leave the CNM blank." Response.End End if
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|