Hi,

Will someone show me how to correctly phrase this function. The goal is to trim left and right white spaces:
Code:
<script type="text/javascript">
function checkForm()
{
    var  cmessage;
    with(window.document.msgform)
    {
        cmessage = message;
    }    
    if(trim(cmessage.value) == '')
    {
        alert('Please enter your message');
        cmessage.focus();
        return false;
    }
    else
    {  
        cmessage.value = trim(cmessage.value);
        return true;
    }
}

 function trim(s)
      {
        return s.replace(/^\s*|\s*$/g, '');
      }
</script>
I am receiving an error: 's has no properties'

Thanks,

Andy