必填属性在我的表单中不起作用

时间:2018-04-04 10:28:54

标签: html css

这是我的代码: 我在<form></form>标签内添加了提交输入类型,我的应用程序中只有一个表单。我使用PHP代码设置了值(这是什么原因?如果是,有哪些替代品可用?)

&#13;
&#13;
<form id="form2" method="POST" action=""  enctype="multipart/form-data">
    <fieldset style="padding:0px 20px 0px 20px;">
        <h5 style="color:#6d7fcc;"><b>Company Details <div style="border-style:solid; border-width:.5px; float:right; width:870px; margin-top:8px; margin-right:20px; color:black;"></div> </b></h5><br>
        <div id="col_sep">
            <h5 style="color:#7B7D7D"><b>Company Name</b></h5>
            <input type="text" name="emp_name" id="emp" style="width:400px; height:30px;" value="<?php if($row1->company_name!=null){echo $row1->company_name;} else {echo ' ';} ?>" disabled="disabled">
            <br><br>
            <h5 style="color:#7B7D7D"><b>Website* </b></h5>
            <input type="text" name="message" style="width:400px; height:30px;" value="<?php if($row1->website!=null){echo $row1->website;} else {echo ' ';} ?>" required />
            <br><br>
            <h5 style="color:#7B7D7D"><b>Select Country* </b></h5>
            <select id="country" name ="country" style="width:200px; height:30px;" value="<?php if($row1->country!=null){echo $row1->country;} else {echo ' ';} ?>" required></select>
            <br><br>
            <h5 style="color:#7B7D7D"><b>Select State* </b></h5>
            <select name ="state" id ="state" style="width:200px; height:30px;" value="<?php if($row1->state!=null){echo $row1->state;} else {echo ' ';} ?>" required ></select>
            <br><br>
            <h5 style="color:#7B7D7D"><b>Company Address</b></h5>
            <textarea name="address" style="width:350px; height:150px;  border:1px solid #7B7D7D; resize:none;" value="<?php if($row1->address!=null){echo $row1->address;} else {echo ' ';} ?>"></textarea>
            <br><br>
        </div>
        <div id="col_sep">
            <h5 style="color:#7B7D7D"><b>Company Logo</b></h5>
            <input type='file' id="c_logo" onchange="readURL(this)" name="logo" />
            <img id="blah" src="<?php if($row1->logo!='img/animie_cam.jpg'){echo $row1->logo;} else {echo 'img/animie_cam.jpg';} ?>" alt="your image" />
            <br><br>
            <h5 style="color:#7B7D7D"><b>Landline</b></h5>
            <input type="text" name="landline" id="emp" style="width:350px; height:30px;" value="<?php if($row1->landline!=0){echo $row1->landline;} else {echo ' ';} ?>">
            <br><br>
            <h5 style="color:#7B7D7D"><b>Mobile* </b></h5>
            <input type="text" name="mobile" style="width:350px; height:30px;" value="<?php if($row1->mobile!=0){echo $row1->mobile;} else {echo ' ';} ?>" required />
            <br><br>
            <h5 style="color:#7B7D7D"><b>About Company</b></h5>
            <textarea name="about" style="width:350px; height:150px;  border:1px solid #7B7D7D; resize:none;" value="<?php if($row1->country!=null){echo $row1->country;} else {echo ' ';} ?>"></textarea>
            <br><br>
        </div>
        <input style="margin:20px 0px 30px 60px; width:70px; height:35px; background-color:#C52B1E; color:white; border-radius:8px;" id="save_up" type="submit" value="Save">
    </fieldset>
</form>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您需要将{echo ' ';}更改为{echo '';},因为空格就是角色。

如果您需要使用修剪空间字符串进行验证,则需要使用javascript。