Text field problem!

Hello:) I have a big problem! I made a highscore table where you have to enter your name. And when there is no name entered then the movie stops. I tried this script:

on (press){
if (_root.name eq “”){
stop();
}else{
play();
}
}

But when the user in the name field presses space bar and presses OK movie plays… What to do?

That happends because " " (a space) is different than “” (an empty string).
You can remove the extra spaces before and after the string. Something like this should do it:

String.prototype.removeSpaces = function() {
	var t = this;
	while (t.charAt(0) == " ") {
		t = t.substring(1, t.length);
	}
	while (t.charAt(t.length-1) == " ") {
		t = t.substring(0, t.length-1);
	}
	return t;
};
//i.e:
my_string = "           ";
trace(my_string.removeSpaces() == "");//outputs 'true' (means 'my_string' is an empty string)