JS replaces the carriage return example in the text field

  • 2020-03-30 01:49:10
  • OfStack

 
<html> 
<head> 
<title> Headless document </title> 
<script type="text/javascript"> 
function aa() 
{ 
s=form1.t1.value; 
s=s.replace(//n|/r/g,"");//  add g Global substitution, just replace the first one   Is a carriage return, is a newline character  
form1.t1.value=s; 
} 
</script> 
</head> 
<body> 
<form name="form1"> 
<textarea name="t1" style="height: 74px"></textarea> 
<input type="button" value="aa" onclick="aa()"> 
</form> 
</body> 
</html> 

Related articles: