|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > form field length validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|