首页javascripttext_inputJavascript Form - 如何处理TextArea on change事件

Javascript Form - 如何处理TextArea on change事件

我们想知道如何处理TextArea on change事件。


<html>
<head>
<script type="text/javascript" language="javascript">
function DisplayValue(){
    if(document.MyForm.MyTextField.value!==""){
        console.log("The value entered was \n" + document.MyForm.MyTextField.value);
    }
    else{
        console.log("The text field was empty!\nPlease enter your name.");
    }
}
</script>
</head>
<body>
    <form name="MyForm" action="" method="Post" onsubmit="DisplayValue()">
        <input type="text" name="MyTextField"/><P>Enter your name</p>
        <input type="submit" value="Click to Submit"/>
    </form>
</body>
</html>