Jump to content

Error messages


ShaolinF

Recommended Posts

<?php

$textbox=$_POST['textbox'];

if($textbox==""){
  echo"
  <form action='?' method='post'>
  <textarea cols='20' rows='4' name='textbox'>
   $textbox
  </textarea>
  </form>
  ";
  }else{
  echo"You listened to me ";
  }

Link to comment
Share on other sites

You could also do it with Javascript (I would do it with PHP too if you were going to do it with javascript):

 


<script language="javascript">
<!--
function Submitted(form) {
if(form.textbox.length < 1) {
alert('Please enter something in the textarea.');
return false;
}
return true;
//not sure if textbox.length is the right format.... I don't use javascript to validate forms very often
//also, you could alter a div or just plain write something if it failed instead of alerts, which are like insanely annoying to me
}
//-->
</script>

<form action="" method="POST" onsubmit="return Submitted(this);">
<textarea name='textbox' id='textbox'>

</textarea>
</form>

Link to comment
Share on other sites

Thanks for the imput guys but I don't know how to implmenet it within html.

 

Here is my textbox:

<p>Character string shown: <input type="text" name="validator" id="validator" size="20" /></p>

 

And my submit button:

<button type="submit" value="Continue">Continue</button>

Link to comment
Share on other sites

What corbin did you can just do:

 

<form name="submit" method="post" action="page.php" onSubmit="Submitted(submit)">
<textarea name="textbox" cols="30" rows="14"></textarea>
<br><input type="submit" value="Submit">
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.