Developed a form with the functionality to move placeholders in a textarea upwards when clicked. The goal is to increment the height of the textarea by 1 row for every line break. However, I am uncertain about what to include in the if statement of my JavaScript function to verify the presence of a line break:
//function SetNewSize(textarea) {
// if (textarea.value.length > 106) {
// textarea.cols += 1;
// textarea.rows += 1;
// } else {
// textarea.cols = 2;
// textarea.rows = 2;
// }
//}
function SetNewSize(textarea) {
if (textarea.rows > 1) {
textarea.rows += 1;
} else {
textarea.rows = 2;
}
}
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
width: 100%;
min-height: 300px;
}
form {
width: 600px;
margin: 2em auto;
font-family: 'Source Sans Pro', sans-serif;
font-weight: 300;
font-size: 22px;
}
form legend {
font-size: 2em;
margin-bottom: 1em;
width: 100%;
border-bottom: 1px solid #ddd;
}
.float-label .control {
float: left;
position: relative;
width: 100%;
border-bottom: 1px solid #ddd;
padding-top: 23px;
padding-bottom: 10px;
}
/* More CSS styles here */
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml>
<head runat="server">
<title></title>
</head>
<body>
<form class="float-label" spellcheck="false">
<legend>Float Label Demo</legend>
<!-- more HTML code here -->
</form>
</body>
</html>