# How do I force a user to enter their name

**URL:** <https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161>\
**Category:** flash\
**Created:** [September 13, 2004, 7:47pm UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161 "2004-09-13T19:47:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![am\_oxfordinspir](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@am\_oxfordinspir](https://forum.kirupa.com/u/am_oxfordinspir)\
**Post date:** [September 13, 2004, 7:47pm UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/1 "2004-09-13T19:47:40Z")

</div>

Does anybody know how to make a user enter their name in a text box. I’ve tried if else on the enter button but that didn’t seem to work?

---

<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:** [September 13, 2004, 8:50pm UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/2 "2004-09-13T20:50:06Z")

</div>

I think using a text box and a few if statements should do the trick.

Only continue playing (i.e. to the next frame) if the text box has a length greater than 1.

---

<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:** [September 13, 2004, 9:01pm UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/3 "2004-09-13T21:01:15Z")

</div>

```auto

if(textfieldname.text == ""){
errorMsg.text = "Please Enter Your Name";
}else{
// code here
}

```

---

<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:** [September 13, 2004, 9:24pm UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/4 "2004-09-13T21:24:37Z")

</div>

Try this:

```auto
labelFormat = new TextFormat();
labelFormat.bold = true;
labelFormat.color = "0x000066";
labelFormat.font = "_sans";
labelFormat.size = 9;

inputFormat = new TextFormat();
inputFormat.bold = true;
inputFormat.color = "0x666666";
inputFormat.font = "_sans";
inputFormat.size = 9;

goFormat = new TextFormat();
goFormat.bold = true;
goFormat.color = "0x666666";
goFormat.font = "_sans";
goFormat.size = 9;

_root.createEmptyMovieClip("nameBoxMC", 1);
with (_root.nameBoxMC) {
	_x = 175;
	_y = 150;
	moveTo(0,0);
	lineStyle(1, 0xCCFFFF, 100)
	lineTo(200, 0);
	lineTo(200, 100);
	lineTo(0, 100);
	lineTo(0,0);
	createTextField("labelTXT", 1, 50, 35, 100, 15);
	with (labelTXT) {
		text = "Enter your name:"
		setTextFormat(labelFormat);
	}
	createTextField("nameTXT", 2,50, 50, 100, 15);
	with(nameTXT) {
		text = "your name"
		type = "input";
		border = "true";
		borderColor = "0x0066FF";
		setTextFormat(inputFormat);
	}
}

_root.createEmptyMovieClip("goMC", 2)
with (_root.goMC) {
	_x = 325;
	_y = 225;
	moveTo(0,0)
	lineStyle(1, 0xFFCCFF, 100);
	lineTo(30, 0);
	lineTo(30, 15);
	lineTo(0,15);
	lineTo(0,0);
	createTextField("goTXT", 1, 6, 1, 20, 20);
	with (goTXT) {
		text = "GO";
		setTextFormat(goFormat);
	}
}

_root.goMC.onRelease = function() {
		if (_root.nameBoxMC.nameTXT.text == "") {
			return;
		} else if (_root.nameBoxMC.nameTXT.text == "your name") {
			return;
		} else {
			trace("You're In!");
		}
	}

```

---

<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:** [September 14, 2004, 12:43am UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/5 "2004-09-14T00:43:43Z")

</div>

You **love** using emptyMovieClips newhopekenny!!!  
Just something I’ve noticed…

---

<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:** [September 14, 2004, 5:50am UTC](https://forum.kirupa.com/t/how-do-i-force-a-user-to-enter-their-name/64161/6 "2004-09-14T05:50:48Z")

</div>

Why yes, but it’s the only way to programmatically create movieClips!

I love trying to do it all via AS, instead of ever touching the rectangle tool, or F8. It’s like a puzzle I know how to solve, I just have to figure out what pieces to use… 😉
