PDA

View Full Version : A very simple variable question


simontheak
09-13-2002, 12:41 PM
I feel rather silly writing this, but I think I'm stuck.

All I want to do is check the value of a text field in a form I'm creating. If the field is empty I want to pop up a little message in another dynamic text field (variable 'error') saying something along the lines of please fill in your first name.

Here's the code I've got on the button:

on (release, keyPress "<Enter>") {
if(_root.form.firstName==""){
error="Please Enter a first Name"
}
else{
error="That's ok"
}
}

It seems to work fine if I place a specific word in the quotation marks at the top ... but I just can't get it to recognise the fact that the firstName variable is empty!

Thanks for any help

M0nk3y Sy
09-13-2002, 12:55 PM
try:


if(_root.form.firstname==null)
//or
if(_root.form.firstname==undefined)


-Sy

simontheak
09-13-2002, 01:08 PM
Thanks very much. That's done the trick nicely.

Just wondering though if there was anyway to stop people just typing a space in the box to get around the code.

Thanks very much for your help again

M0nk3y Sy
09-13-2002, 01:10 PM
no worries.

hmm, just a thought, it actually might be better to use both?


if((_root.form.firstName=="") || (_root.form.firstName==undefined)){


-Sy