# Text field problem!

**URL:** <https://forum.kirupa.com/t/text-field-problem/119243>\
**Category:** Uncategorized\
**Created:** [August 12, 2004, 7:50pm UTC](https://forum.kirupa.com/t/text-field-problem/119243 "2004-08-12T19:50:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HITMANukas](https://avatars.discourse-cdn.com/v4/letter/h/c57346/32.png) [@HITMANukas](https://forum.kirupa.com/u/HITMANukas)\
**Post date:** [August 12, 2004, 7:50pm UTC](https://forum.kirupa.com/t/text-field-problem/119243/1 "2004-08-12T19:50:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.kirupa.com/u/claudio)\
**Post date:** [August 12, 2004, 8:13pm UTC](https://forum.kirupa.com/t/text-field-problem/119243/2 "2004-08-12T20:13:46Z")

</div>

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:

```auto
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)

```
