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.

 

 

Link to comment
Share on other sites

Well i'm getting popup windows with errors, but whenever i click "ok" button on them, i'm getting to the "posalji.php". Basically that's not preventing from calling the other php. So all i need is to stop calling that one after the popup.

Link to comment
Share on other sites

 <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'];
  }
?>

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.