Javascript to check field is empty then execute rest of script

I have found this bit of code that nearly does what I want.

Basically 3 input fields, I want to copy t2 to t3 as it's typed but only if t1 contains data AND t3 is empty:

<input type="text" id="t1" /> 
<input type="text" id="t2" />
<input type="text" id="t3" />

 <script> var t2 = document.getElementById('t2'); t2.onkeyup = t12.onchange = function() {     
document.getElementById('t3').value = this.value; }; 
</script>

Thanks

if((document.getElementById('t1').value) && (!document.getElementById('t3').value)) { ... }

You realize of course this will stop copying after the first character, as t3 will no longer be empty.

You should do <script type='text/javascript'> fyi.

Ah, right - that's no good!! so how would I modify the script to copy the contents of t2 to t3 as the user moves away from t2 (ie tabs out of the text box)? I guess I need onblur?

1 other query:
Thinking about the order in which the data will be entered which I have go slightly wrong - t2 will be entered before t1 so I need the script to copy t2 to t3 when t1 is filled?
Thanks for the help - again

Yee, will do this in the future - I was not sure it was required anymore :o

---------- Post updated at 08:53 PM ---------- Previous update was at 07:10 AM ----------

I am not quiet sure what to do with this, do I put the rest of the code between the curly brackets like this??:

<script type='text/javascript'>
if((document.getElementById('t1').value) && (!document.getElementById('t3').value))
{
    if((document.getElementById('t1').value))
      {
       var t2 = document.getElementById('t2');
        t2.onblur = function() 
            {
            document.getElementById('t3').value = this.value;
            }
        }
};
</script>

Nothing is copied :confused:

You can try this code

if(document.getElementById("question").value.length == 0)
{
    alert("empty")
}

and see if this works for you.