Jump to content

Little help with submit button and field check.


evlj

Recommended Posts

Hi there once again, sry for previous wrong section, i guess this time i'm on the right place ;p

 

Well i need following:

 

I have few forms (input fields) with requested informations, also i have other .php file which i'm calling to send a form. Now i need to know how can i do a check for those fields if they are empty or not. If they are, i need to STOP submiting the form (calling the other .php).

 

Codes:

 

Form:

 <form name="f1" form method="post" action="posalji.php"/>

Field:

<input type="text" name="hp1" size="20"/>

Submit:

<input name="f1" type="image" src="registruj.png" onclick="if(f1.hp1.value.length==0) alert('Error: field can't be empty'); else f1.submit(); if(f1.hp2.value.length==0) alert('Error: field can't be empty'); else f1.submit();"/>

There are more than one field, that's why you can see more errors in submit. Well all i need is "die" or "stop" calling the "posalji.php" from action above.

 

Sry 4 poor english.

 

 

 <form name="f1" form method="post" action=""/>
<input type="text" name="hp1" size="20"/>
<input type="submit" name="submit" value="Submit">
</form>


<?php
if (isset($_POST['submit'])) 
      {
  if (empty($_POST['hp1']))
     {
	 echo "Empty field";
     } else echo $_POST['hp1'];
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.