# Text field problem!

**URL:** https://forum.kirupa.com/t/text-field-problem/60810
**Category:** flash
**Created:** [August 12, 2004, 7:50pm UTC](https://forum.kirupa.com/t/text-field-problem/60810 "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/60810/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: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 12, 2004, 8:13pm UTC](https://forum.kirupa.com/t/text-field-problem/60810/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)

```
