![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form within the html document. |
#2
| |||
| |||
|
#3
| |||
| |||
|
|
In article <75e8d381.0309120637.2e8fe4b9 (AT) posting (DOT) google.com>, KathyBurke40 (AT) attbi (DOT) com enlightened us with... Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form within the html document. (substitute your form name in here) var l = document.formname.elements.length; for (var i=0; i<l; i++) { var e = document.formname.elements[i]; if (e.type=="text") { if (isBlank(e)) { alert("Blank!"); return false; } } } return true; function isBlank(strObject) { /* Returns false if the field has any non-space characters, true if not. You must pass in an input (text) object (not the value) */ var index; var myChar; if (! strObject) { return true; } else { var str = strObject.value; } for (index = 0; index < str.length; index ++) { myChar = str.charAt(index); if (myChar != " ") { return false; } } return true; } ------------------------------------------------- ~kaeli~ Hey, if you got it flaunt it! If you don't, stare at someone who does. Just don't lick the TV screen, it leaves streaks. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace ------------------------------------------------- |
![]() |
| Thread Tools | |
| Display Modes | |
| |