Check if a text box contains a symbol and delete everything after the symbol


I have an email page that loads up when I click on a button. The 'To:' field is containing too many emails and I would like to run a script for when the page loads to check if the box contains a semi-colon and if it does, it should remove the semi-colon and any text after it.

This is the text area's HTML code when I view the script on the page:

<textarea class="EDIT" name="email_to" id="email_to" maxlength="8000" rows="1" style="height:2em;" cols="80">[email protected];[email protected];</textarea>

So when the page loads the script should check the email_to field. For example:

[[email protected];[email protected]]

should have its semi-colon removed as well as anything after it to leave this:

[[email protected]]

What I have so far is as follows

function checkTextField(email_to) {
    var check = (email_to.indexOf(';');
    if (check != -1)
        check.replace(/;.*/, '');

My main problem I think is that when I do a console.log(email_to) it gives me all of styles and everything for the textbox, and all I want is the text held in the textarea.

It may not need to be in a function and could just be an onload script but I am new to javascript so I am not sure what to use.

To my understanding you want to be operating on "email_to.value", not the "email_to" textarea itself