Как да проверя дали даден ред в текстареа е празен?

<?php

$Content = stripslashes(trim($_POST['TextAreaName']));

$Rows = preg_split("/" . chr(13) . chr(10) . "/", $Content);

foreach ($Rows as $id => $row)
{

$row = trim($row);

echo "Row #" . $id . " is " . (empty($row) ? "empty":"not empty");

}

?>
 
madmax3 каза:
<?php

$Content = stripslashes(trim($_POST['TextAreaName']));

$Rows = preg_split("/" . chr(13) . chr(10) . "/", $Content);

foreach ($Rows as $id => $row)
{

$row = trim($row);

echo "Row #" . $id . " is " . (empty($row) ? "empty":"not empty");

}

?>
С javascript?
 
Заповядай:
Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>Web page</title>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
	<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
		function check() {
			if(document.getElementById("comment").value == "") {
				alert("Please fill the gap!");
			}
		}
	</script>
</head>

<body>
	
	<form>
		<textarea id="comment" cols="30" rows="5"></textarea><br /><br />
		<input type="button" value="check" onclick="check()" />
	</form>
	
</body>

</html>
 
fenixpz каза:
Заповядай:
Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>Web page</title>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
	<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
		function check() {
			if(document.getElementById("comment").value == "") {
				alert("Please fill the gap!");
			}
		}
	</script>
</head>

<body>
	
	<form>
		<textarea id="comment" cols="30" rows="5"></textarea><br /><br />
		<input type="button" value="check" onclick="check()" />
	</form>
	
</body>

</html>
Не искам това.Това е за цялата текстареа ,а аз искам за определен ред в тази текстареа!
 
Код:
<script type="text/javascript">
function chtxt(txtel) {
var text;
var elnum = 0;
var elns = new Array();
txtel = document.getElementById(txtel).value;
text = txtel.split("\n");
for (i=0;i<text.length;i++) if ((text[i]+"").replace(/^\s+$/g,"")=="") elns[elnum++] = i+1;
return elns;
}
</script>
<textarea id="ct"></textarea>
<input type="button" value="Proveri" onclick="alert('prazni redove sa: '+chtxt('ct'))" />
Връща ти масив с празните редове, ако това искаше.
 

Back
Горе