473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Stopping long text submissions without spaces

I have a section on my webpage that shows the most recent members who
joined, but I am worried that if someone joines with the name
'aaaaaaaaaaaaaaaaaa' that since there are no spaces that it will
stretch the box it is in and look ugly. What I am trying to do to fix
this by having a script that runs at 'Onsubmit' and checks the
username. Unfortunatly I have no idea how to do this, even though I do
have a small understanding of JS :D

How would I get the following to work in JS?

------------------
If LEN(Username_from_database) is greater than 8 characters AND the
total Spaces is less that 1, alert 'please limit the length of
continus words'.
------------------

Ok, thanks all.
Jul 20 '05 #1
2 1422
th**************@hotmail.com (Boolean) writes:
What I am trying to do to fix this by having a script that runs at
'Onsubmit' and checks the username.
You should also check on the server. It is easy to bypass client-side
validation, deliberatly or accidentally.
Unfortunatly I have no idea how to do this, even though I do have a
small understanding of JS :D How would I get the following to work in JS?

------------------
If LEN(Username_from_database) is greater than 8 characters AND the
total Spaces is less that 1, alert 'please limit the length of
continus words'.
------------------


var name = Username_from_database;
if (name.length > 8 && name.indexOf(" ")==-1) {
alert("please limit the length of continus words");
}

That limit might be a problem for, e.g., Christopher, Christian,
Jeramiah, Charlotte, Archibald, etc., if they want to register under
their name. That is, I think a length of 8 is too low a limit.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Boolean wrote on 01 feb 2004 in comp.lang.javascript:
I have a section on my webpage that shows the most recent members who
joined, but I am worried that if someone joines with the name
'aaaaaaaaaaaaaaaaaa' that since there are no spaces that it will
stretch the box it is in and look ugly. What I am trying to do to fix
this by having a script that runs at 'Onsubmit' and checks the
username. Unfortunatly I have no idea how to do this, even though I do
have a small understanding of JS :D

How would I get the following to work in JS?


t = "Hello world 1234567890123568"
t = t.replace(/(\S{12})/g,"$1 ")
alert(t)

tested

This will put a space after every 12th non whitespace character.

================================

so:

<form onsubmit='t=document.getElementById("k").value;
t = t.replace(/(\S{12})/g,"$1 ";return true)'>
<input id="k">

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Philipp Lenssen | last post by:
I don't know the English word, but I'm referring to the double-dash which is used to separate parts of a sentence. I'm using — so far. Now I saw – which is slightly shorter. Some sites use --. ...
6
by: Dave | last post by:
I have a situation where I want to react to a ctrl-click on a <span> and it works in Netscape and Firefox browsers but in IE I have a problem. In IE I do catch the ctrl-click but IE also renders...
12
by: skip | last post by:
Is there a module out there that will generate an image with a random text string such as the confirmation images you see on various websites? I'm thinking I'm going to have to add that to the...
4
by: bjm | last post by:
I am writing a program that will automate a series of application installations. I want to give the user the option of stopping the program's execution in between installations (for example, give...
17
by: kevgibbo | last post by:
Hi, I'm currently having a problem where a long URL or a line of text with no spaces will break the design of a webpage, http:// blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-...
10
by: Mo | last post by:
Hi, I am trying to write a code to build a string 768 characters long. This string is going to be written to a file which is then read by another application. The format of the string is already...
6
by: Chad | last post by:
I have a simple little program that brings up asks the user to enter a note, then is supposed to place that note into a text file when the user hits the submit button. However, when the user hits...
15
by: removeps-groups | last post by:
How to wrap text in <ptag if the text has no spaces and is very long? Here is an example: ...
1
by: raghudr | last post by:
Hi all, I am displaying a splash screen for which i have created a thread.Since my whole project is launched by windows service and that service will start automatically at the start of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.