简体   繁体   English

输入元素周围的随机红色边框

[英]Random Red Border Around Input Elements

Does anyone know what the red border that sometimes gets put around input elements on webpages is? 有人知道网页上的input元素有时会出现红色边框吗? Is it from HTML5 or jQuery? 是HTML5还是jQuery? I have seen it when I am using required as an attribute and also when I use jQuery's change function (as well as on("change") , obviously). 我在将required用作属性时以及在使用jQuery的change函数(以及on("change")时都看到了它。 At first I thought it was when you don't have the right pattern in an input field on form submit, but recently I found it happening with this code: 起初我以为是您在表单提交的input字段中没有正确的pattern ,但是最近我发现此代码发生了这种情况:

<form id="assessform" action="assessment.php" method="post" enctype="application/x-www-form-urlencoded" name="assessform">

    <div data-test-ques="met_with">

        <label data-test-num="met_with" for="met_with">Met With </label>

        <input type="text" name="met_with" id="met_with" value="" required="required" autofocus="autofocus" />

    </div><br /><br />

    <div data-test-ques="taken_by">

        <label data-test-num="taken_by" for="taken_by">Assessment Taken By </label>

        <input type="text" name="taken_by" id="taken_by" value="" required="required" />

    </div>
</form>

jQuery code: jQuery代码:

$("#met_with, #taken_by").change(function() {
    if($("#met_with").val() == met_with || $("#taken_by").val() == taken_by) {
        met_taken_change = 0;
    }
    else {
        met_taken_change = 1;
    }
});

I get the required thing, but why here? 我得到了required东西,但是为什么在这里?

Screenshot attached. 屏幕截图已附上。 在此处输入图片说明

It's not a random behavior, it's just a different implementation of the html5 spec in FF for the 'required' input attr. 这不是随机行为,只是FF中html5规范针对“必需”输入attr的不同实现。

FF adds a red border to help us focus on the problem, you can see it here . FF添加了一个红色边框来帮助我们专注于问题,您可以在此处看到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM