textarea的“必需”即使该值为空,属性也不起作用 [英] textarea's "required" attribute doesn't work even though the value is empty

查看:138
本文介绍了textarea的“必需”即使该值为空,属性也不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



列表框工作正常,但textarea框没有说明

 <!DOCTYPE html> 
< html>
< head>
< title>评分&评论和LT; /标题>
< body>
< form>

< span>客户服务*< / span>
< span>
< select name = customer id = aa required>
< option selected =ratevalue =disabled> rate< / option>
< option value = 1> 1< / option>
< option value = 2> 2< / option>
< option value = 3> 3< / option>
< option value = 4> 4< / option>
< option value = 5> 5< / option>
< / select>
< / span>
< br>< br>
< span>物有所值*< / span>
< span>
< select name = money id = aa required>
< option selected =ratevalue =disabled> rate< / option>
< option value = 1> 1< / option>
< option value = 2> 2< / option>
< option value = 3> 3< / option>
< option value = 4> 4< / option>
< option value = 5> 5< / option>
< / select>
< / span>

< div>
< textarea name =reviewsrows = 11 cols = 50 maxlength = 250 required>
< / textarea>
< / div>

< div id = submit>
< br>
< input type = submit name = submit value = submit>
< / div>

< / form>
< / body>
< / html>


解决方案

 < textarea name =reviewsrows = 11 cols = 50 maxlength = 250 required>< / textarea> 


I created a simple page with list box and text area with conditions that all should be required.

List box are working fine, but textarea box doesn't tell that the field is required to be filled.

<!DOCTYPE html>
<html>
<head>
<title>Ratings & Reviews</title>
<body>
<form>

<span>Customer Service*</span>
<span>
    <select name=customer id=aa required>
        <option selected="rate" value="" disabled>rate</option>
        <option value=1>1</option>
        <option value=2>2</option>
        <option value=3>3</option>
        <option value=4>4</option>
        <option value=5>5</option>
    </select>
</span>
<br><br>
<span>Value for money*</span>
<span>
    <select name=money id=aa required>
        <option selected="rate" value="" disabled>rate</option>
        <option value=1>1</option>
        <option value=2>2</option>
        <option value=3>3</option>
        <option value=4>4</option>
        <option value=5>5</option>
    </select>
</span>

<div>
    <textarea name="reviews" rows=11 cols=50 maxlength=250 required>
    </textarea>
</div>

<div id=submit>
    <br>
    <input type=submit name=submit value=submit>
</div>

</form>
</body>
</html>

解决方案

You have empty space inside text area, remove it:

 <textarea name="reviews" rows=11 cols=50 maxlength=250 required ></textarea>

这篇关于textarea的“必需”即使该值为空,属性也不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆