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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 12th, 2003, 01:00 PM
friendly_state friendly_state is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 11 friendly_state User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
form field length validation

Hello, I am a newbie when it comes to asp and needed a little help with form field length validation.

Alright what I need to be able to do is to make the field it's maxlength if the user does not enter enough characters.

<input type="hidden" name="B" size="10" maxlength="6" value="">

so basicly if the user enters a 5, 4, 3, or 2 digit number the input will be forced to it's maxlength. I need this because I am writing to an SQL db and am combining multiple form inputs into one field in the db table ie(variable = A&B&C&D)

On a different webpage I need to display the variables. I am doing this by string manipulation functions like the one below.

Nbr = mid(aTable1Values(DATA, aRowLoop), 6, 6)

(DATA = A&B&C&D)

Any help would be much appreciated

Adam

Reply With Quote
  #2  
Old August 12th, 2003, 01:16 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
First thing first, the approach you are using is BAD

In fact, its a BAD database design to try and do what you want.

Why not make them fields instead of concatenating them into one field ?

What if eventually wanted to search on the B like in your exmaple?

No no no my friend, re-design your database, trust me!

Make them fields

Now if for some strange reason you CAN'T then simply insert the value from your <form> seperating each value with a string delimiter such as --> | <-- for example or --> ; <--

The end result should look something like:
variable = A|B|C|D
If --> | <-- is your choice of delimiter

Now when you read/retrieve the data instead of making/using :
Nbr = mid(aTable1Values(DATA, aRowLoop), 6, 6)

Simply use the Split() function...something like

<%
Dim Arr
Arr = Split(variable, "|")

'The variable Arr then becomes an array.
'You can then access the content of the array using this technique
Response.Write Arr(0)
Response.Write Arr(1)
etc...
%>


Hope this helps!
Sincerely

Vlince

PS: But again, I strongly recommend NOT to use that approach(the one where you concatenate all the form fields value into ONE variable)

I'm not saying its bad, it depends on the situation, and your situation requires something different.

Reply With Quote
  #3  
Old August 12th, 2003, 02:15 PM
friendly_state friendly_state is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 11 friendly_state User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There's no other choice for the db design, I'm stuck with what I got.
Thanks for the split array function idea, I'm going to give it a try tomorrow.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > form field length validation


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 | 
  
 





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