This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is this doing?

 
rich werth
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can anyone tell me what this is doing? This is the whole function and does what it is supposed to do.....Check to see if data is missing in form fields but it doesn't check to see if a user enters in just spaces.
function validateMe(theForm)
{
var emptyFields=""
var size = <%=splitSize%>*5;
for (i=0; i <= size; i++)
{

if(theForm.elements[i].value=="")
{
comma=(emptyFields=="")?"":", "
emptyFields=emptyFields+comma+theForm.elements[i].name}}
{
if (emptyFields!="")
{
alert('All Fields must contain data. \n'+'Please return and complete the form.')
return false
}
}
}
 
James Swan
Ranch Hand
Posts: 403
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why JavaScript didn't include trim methods on the String object but all is not lost.
The following code adds that functionality to Strings, just paste it somewhere in your script tag, or have it as an include file.
To use the trim functions do something like:
if (document.myForm.myTextbox.trim() == "") {
alert("text must be entered");
}
Here is the code:
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hey, James! That was cool! I didn't know you could extend stuff that way in Javascript. I am so going to be using that.
[ May 02, 2002: Message edited by: Bodie Minster ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic