Author |
Topic  |
|
samirving
Starting Member
United Kingdom
47 Posts |
Posted - 20 May 2002 : 15:58:43
|
I would like to know if it is in anyway possible to limit the amount of charactesr used in a user name.
I have recently has the problem that people are registering with long user names, and using _ which makes it like this
john_smithy_the_first
when viewing forums.asp If the author and the last poster has long names like this, then the whole table is thrown and 60% are of these two columns, and the TOPIC column is squeezed into about 100 pixels in width !
|
|
Hamlin
Advanced Member
    
United Kingdom
2386 Posts |
Posted - 20 May 2002 : 16:27:39
|
Well for the _ part, in the file inc_functions.asp, around line 2249 is says this
sInvalidChars = "!#$%^&*()=+{}[]|\;:/?>,<"
if you add a _ to this list it should stop people adding that char to their username.
so it would be
sInvalidChars = "!#$%^&*()=+{}[]|\;:/?>,<_"
i've not tested this but as far as i can tell it should work
you may also want to add it to a line in register.asp around line 100
Err_Msg = Err_Msg & "<li> You may not use any of these chars in your username !#$%^&*()=+{}[]|\;:/?>,< </li>"
to
Err_Msg = Err_Msg & "<li> You may not use any of these chars in your username !#$%^&*()=+{}[]|\;:/?>,<_ </li>"
For lenght you could do something like
If Len(username) > "50" then error with name etc end if
you could add a check in the register.asp file
if not UserNameLenght(Request.Form("Name")) then Err_Msg = Err_Msg & "Name to long" end if
and add a fucntion to check the username...
but some one who knows more about this may have a better idea
Edited by - Hamlin on 20 May 2002 17:17:40 |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
|
Hamlin
Advanced Member
    
United Kingdom
2386 Posts |
Posted - 20 May 2002 : 16:58:53
|
ok after messing around a bit i think this should work for you..
in register.asp add this if not UserNameLength(Request.Form("Name")) then Err_Msg = Err_Msg & "user name to long" end if
after this..
if not IsValidString(Request.Form("Name")) then Err_Msg = Err_Msg & "<li> You may not use any of these chars in your username !#$%^&*()=+{}[]|\;:/?>,< </li>" end if
and then in the file inc_function.asp
add the following code before the line "Sub WriteFooter() %>"...
Function UserNameLength(userName) if Len(userName) > "3" then UserNameLength = False else UserNameLength = True end if end function
you can change the red number to max length name that you want.
as stated b4 someone who knows ASP may have a better solution 
Up the Arse!
Edited by - Hamlin on 20 May 2002 17:17:20 |
 |
|
samirving
Starting Member
United Kingdom
47 Posts |
Posted - 20 May 2002 : 18:04:32
|
Thanks Hamlin
I could not get your 2nd suggestion to work- tho I followed exactly your instructions !
But I got your first suggestion to work, benning the use of _ in the user name registration process !
Cheers Mate !
|
 |
|
Hamlin
Advanced Member
    
United Kingdom
2386 Posts |
Posted - 20 May 2002 : 18:12:52
|
quote:
Thanks Hamlin
I could not get your 2nd suggestion to work- tho I followed exactly your instructions !
But I got your first suggestion to work, benning the use of _ in the user name registration process !
Cheers Mate !
the second one should work fine...at least it seems to on my computer ah well i'm pleased that the _ bit worked, did u get any soecific error when trying it?
.::Hamlin::. Up the Arse! |
 |
|
samirving
Starting Member
United Kingdom
47 Posts |
Posted - 20 May 2002 : 18:18:01
|
Strangley enough NO !
I made the changes in the 2 files you said (exactly like you said).
Then I tried to register using a long user name that exceeded the numer (in red) that I allowed.
The next page just said REGISTRATION COMPLETE ! (just as normal) !
So it was like I did not do anything at all !
oh well- I am happy !
|
 |
|
_barbara
Junior Member
 
Germany
123 Posts |
Posted - 20 May 2002 : 18:20:19
|
To limit the length of usernames, you can also set a maxlength for the input field in the registration form. Go to your inc_profile.asp, about line 182 and add the red part:
<INPUT name="Name" size="25" maxlength="10" value="<% =ChkString(rs("M_NAME"), "display") %>">
This limits the input length to 10 characters. Change 10 to anything you want.
Barbara
|
 |
|
Hamlin
Advanced Member
    
United Kingdom
2386 Posts |
Posted - 20 May 2002 : 18:35:07
|
quote:
To limit the length of usernames, you can also set a maxlength for the input field in the registration form. Go to your inc_profile.asp, about line 182 and add the red part:
<INPUT name="Name" size="25" maxlength="10" value="<% =ChkString(rs("M_NAME"), "display") %>">
This limits the input length to 10 characters. Change 10 to anything you want.
Barbara
DOH - that was dam simple
.::Hamlin::. Up the Arse! |
 |
|
crash
Advanced Member
    
Netherlands
2064 Posts |
Posted - 20 May 2002 : 18:35:09
|
just out of curiosity: what happens when i set it to 10 right now and i have member names that are longer? meaning that new members will only be allowed 10 characters, but what happens to the already registered ones? for example when they view their profile (or is pop_profile.asp used then?)
 Crash's Site | Crash is from 
|
 |
|
_barbara
Junior Member
 
Germany
123 Posts |
Posted - 20 May 2002 : 18:59:40
|
just tested it in my local forum... When already registered members with longer usernames view or even edit their profiles everything is displayed normally - they can't edit their own usernames anyway. If you, as admin, edit the member's profile you get the username displayed in an input box (so you can edit it) and, here too, the longer ones are displayed correctly and aren't even cut if you update the profile. But when you edit the username you are limited to 10 characters.
Well, test yourself 
Barbara
|
 |
|
crash
Advanced Member
    
Netherlands
2064 Posts |
Posted - 20 May 2002 : 19:02:13
|
of course i will then...
 Crash's Site | Crash is from 
|
 |
|
crash
Advanced Member
    
Netherlands
2064 Posts |
Posted - 20 May 2002 : 19:07:32
|
works fine. thanks for that!
 Crash's Site | Crash is from 
|
 |
|
|
Topic  |
|