Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling length of string from prompt

Status
Not open for further replies.

kristinac13

Programmer
Dec 22, 2005
27
US
Is there a way to control the length of the string a user enters into a prompt window? I have an asp, html, java filled web app and at one point the user receives a prompt and must enter a string. If the string is longer than the width of the prompt window, altho the prompt window allows the string to go on and on, when the page is submitted it does not retain the prompt string and display it as it should. If I keep the characters limited I have no problems. Is it possible to set a prompt window to a set number of characters to accept?

"I don't wanna learn what I'll need to forget!
 
Thank you very much that did it. Sorry for all the trouble.

"I don't wanna learn what I'll need to forget!
 
don't be sorry. just try to make it a habit of supplying as much information as possible (without clogging the page) so we can help you quicker.



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Or, to force the user to only enter less than a set amount of characters, or cancel:

Code:
var maxLength = 25;
var userData = -1;

while (userData == -1 || (userData != null && userData.length > maxLength)) {
	userData = window.prompt('Please enter some data. It should be no more than ' + maxLength + ' characters in length', '');
}

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thank you very much.

"I don't wanna learn what I'll need to forget!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top