...

View Full Version : what is the opposite of undefined when checking if a form field is filled or not



needsomehelp
12-13-2011, 08:42 AM
What I am wanting to do is have my form open up a new part of the form when the previous sections are filled out.

i.e

name field shows, when it has content, the next field opens up for it to be filled out, and so on.

VIPStephan
12-13-2011, 09:57 AM
The opposite of “undefined” is “not undefined”, i. e. either != 'undefined' or check if it’s not empty: != ''

Philip M
12-13-2011, 05:10 PM
Are you looking for something like this?

Each field needs to be validated, with e.g. a minimum length and characters according to the field, e.g. a proper name may contain only letters, hyphen, apostrophe (and perhaps spaces). Telephone numbers and email addresses must be validated appropriately. Only if the validation is passed will the next textbox be revealed. If not a suiatble message should be shown, the textbox cleared, and the focus returned to it.

Be aware that the user may possibly backtrack and change a previously validated entry.



NAME <input type = "text" id = "uname" onblur = "showNext(this,2)">
<br>
<span id = "text2" style="display:none" >
ADDRESS <input type = "text" id = "uaddress" onblur = "showNext(this,3)">
</span>
<span id = "text3" style="display:none">
EMAIL <input type = "text" id = "uemail" onblur = "showNext(this,4)";
</span>

<script type = "text/javascript">
function showNext(which,num) {

var val = which.value;
// validate user entry here as per num, return false if validation not passed. if (num==2) { //validate name field, if (num==3) { // validate address field etc.

// only if validation returns true
var next = "text" + num;
document.getElementById(next).style.display="block";
}

</script>


Quizmaster: In maths, what number is represented by 10 to the power of 3?
Contestant: Six.

rnd me
12-13-2011, 06:30 PM
The opposite of “undefined” is “not undefined”, i. e. either != 'undefined' or check if it’s not empty: != ''

!= 'undefined' is almost always true.
i think you meant != undefined; ...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum