Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果按钮上的文本区域为空,提交将在表单验证中显示成功消息_Javascript_Php_Html_Arrays_Forms - Fatal编程技术网

Javascript 如果按钮上的文本区域为空,提交将在表单验证中显示成功消息

Javascript 如果按钮上的文本区域为空,提交将在表单验证中显示成功消息,javascript,php,html,arrays,forms,Javascript,Php,Html,Arrays,Forms,我试图在单击提交按钮时获取错误消息,但仅从textfield获取消息,而不是从textarea获取消息。这是我的密码。 问题是,如果我提交的字段没有textarea,它将显示成功消息 if(empty($_POST)===false) { if(empty($_POST['offered'])===true||($_POST['description'])===true) { ?>

我试图在单击提交按钮时获取错误消息,但仅从
textfield
获取消息,而不是从
textarea
获取消息。这是我的密码。 问题是,如果我提交的字段没有
textarea
,它将显示成功消息

  if(empty($_POST)===false)
            {
                if(empty($_POST['offered'])===true||($_POST['description'])===true)
                    {
    ?>                    
                        <div class="alert alert-warning alert-dismissible text-center" role="alert">
                        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>Add some offers and descriptions
                        </div>
     <?php
}
  else
    {
    $title = $_POST['offered'];
    $offer = $_POST['description'];
    $data = array(
        $page_id,
        $title,
        $offer
    );
    if ($data)
        {
        $add = add_data($data);
        header('location:hotel1_galery.php?page_id=1 && msg=Add Offers Successfully');
        }
      else
    if (!empty($_POST['offered']) && !empty($_POST['description']))
        {
?>                           
                                <div class="alert alert-danger alert-dismissible text-center" role="alert">
                                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php
        echo "Add offers and descriptions "; ?></div>
    <?php
        }
    }
}
if(空($\u POST)==false)
{
如果(空($_POST['offered'])==true | |($_POST['description'])==true)
{
?>                    
添加一些优惠和说明

您尚未检查此行中是否为空:

更改此项:

if(empty($_POST['offered'])===true||($_POST['description'])===true)
致:


添加一些优惠和说明
尝试以下操作…文本区域的打开和关闭标记之间没有任何空格
if(empty($_POST['offered'])===true||($_POST['description'])===true)
if(empty($_POST['offered'])||empty(trim($_POST['description'])))
<?php

if(!empty($_POST))
        {
            if(empty($_POST['offered']) || empty($_POST['description']))
                {
?>                    
                    <div class="alert alert-warning alert-dismissible text-center" role="alert">
                    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>Add some offers and descriptions
                    </div>
 <?php                  
                }
            else
                {
                    $title=$_POST['offered'];
                    $offer=$_POST['description'];
                    $data=array($page_id,$title,$offer);

                    if($data)
                        {   
                            $add=add_data($data); 
                            header('location:hotel1_galery.php?page_id=1 && msg=Add Offers Successfully'); 
                        }
                    else if(!empty($_POST['offered']) && !empty($_POST['description']))
                        {
?>                           
                            <div class="alert alert-danger alert-dismissible text-center" role="alert">
                            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php echo "Add offers and descriptions "; ?></div>
<?php
                        }               
                }

        }