# Input text

**URL:** <https://forum.kirupa.com/t/input-text/186742>\
**Category:** Uncategorized\
**Created:** [April 24, 2006, 9:32am UTC](https://forum.kirupa.com/t/input-text/186742 "2006-04-24T09:32:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![interfan](https://avatars.discourse-cdn.com/v4/letter/i/cab0a1/32.png) [@interfan](https://forum.kirupa.com/u/interfan)\
**Post date:** [April 24, 2006, 9:32am UTC](https://forum.kirupa.com/t/input-text/186742/1 "2006-04-24T09:32:16Z")

</div>

Hi all!  
I have three text boxes side by side.  
The first two are input boxes and the third is a dynamic text box.  
I want the user to be able to input numbers into box 1(target1a) and multiply it by box 2(target1b) and show the answer in box 3(target1c).  
I’m sure this is simple but I have no idea how to go about it.  
Any help would be greatfully accepted!  
many thanks:)

---

<div class="post-metadata">

**Author:** ![Mirandir](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Mirandir](https://forum.kirupa.com/u/Mirandir)\
**Post date:** [April 24, 2006, 9:50am UTC](https://forum.kirupa.com/t/input-text/186742/2 "2006-04-24T09:50:45Z")

</div>

Something like this:

```auto

// Restrict input to only include numbers and a minus character
target1a.restrict = target1b.restrict = "0-9 \\-";
 
// Setting a function that is run as soon as the contents of 
// target1a or target1b changes.
target1a.onChanged = target1b.onChanged = function()
{
     // Check if contents of target1a or target1b is not a number.
    var a = isNaN(target1a.text) ? 0 : Number(target1a.text);
    var b = isNaN(target1b.text) ? 0 : Number(target1b.text);
 
    // Do the math.
    target1c.text = a * b;
}

```

/Mirandir

---

<div class="post-metadata">

**Author:** ![interfan](https://avatars.discourse-cdn.com/v4/letter/i/cab0a1/32.png) [@interfan](https://forum.kirupa.com/u/interfan)\
**Post date:** [April 24, 2006, 10:15am UTC](https://forum.kirupa.com/t/input-text/186742/3 "2006-04-24T10:15:55Z")

</div>

works like a dream . . .  
thanks - you guys are just great!
