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 } } }
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:
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 ]