20-Nov-2020
.
Admin
Hi Guys,
In this example,I will learn you how to add line breaks to an html textarea.you can easy and simply add line breaks to an HTML textarea.
split(): is a predefined JavaScript function that splits a string into an array using a parameter.
join(): is a predefined JavaScript function that joins an array to convert it into a string using provided parameters.
Example :
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function divide() {
var txt;
txt = document.getElementById('a').value;
var text = txt.split(".");
var str = text.join('.</br>');
document.write(str);
}
</script>
<title></title>
</head>
<body>
<form>
ENTER TEXT:
<br>
<textarea rows="20"
cols="40"
name="txt"
id="a">
</textarea>
<br>
<br>
<input type="submit"
name="submit"
value="submit"
onclick="divide()" />
</form>
</body>
</html>
It will help you...
#JavaScript