javascript - 显示具有特定 CSS 格式的警告消息

标签 javascript w2ui

我看到的对话框如下图所示,

enter image description here

这是提交输入文本后出现的 MAC 地址格式错误的警告消息。我想立即验证输入,而不是提交后。在哪里可以找到这个 css 样式?

最佳答案

试试这个:

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    font-size: 112.5%;
    margin-left: auto;
    margin-right: auto;
    max-width: 40em;
    width: 88%;
}  

/**
 * Form Styles
 */
label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.label-normal {
    font-weight: normal;
}

.pattern {
    color: #808080;
    font-size: 0.8em;
    font-weight: normal;
}

.supports-color .color,
.supports-date .date,
.supports-time .time,
.supports-month .mont {
    display: none;
}

input,
select {
    display: inline-block;
    font-size: 1em;
    margin-bottom: 1em;
    padding: 0.25em 0.5em;
    width: 100%;
}

[type="checkbox"],
[type="radio"] {
    margin-bottom: 0.5em;
    width: auto;
}

.button {
    background-color: #0088cc;
    border: 1px solid #0088cc;
    border-radius: 1px;
    color: #ffffff;
    display: inline-block;
    font-size: 0.9375em;
    font-weight: normal;
    line-height: 1.2;
    margin-right: 0.3125em;
    margin-bottom: 0.3125em;
    padding: 0.5em 0.6875em;
    width: auto;
}

.button:active,
.button:focus,
.button:hover {
    background-color: #005580;
    border-color: #005580;
    color: #ffffff;
    text-decoration: none;
}

.button:active {
    box-shadow: inset 0 0.15625em 0.25em rgba(0, 0, 0, 0.15), 0 1px 0.15625em rgba(0, 0, 0, 0.05);
}
<form>
    <div>
        <label for="text">Text Input</label>
        <input type="text" id="text" required>
    </div>

    <div>
        <label for="minmaxlength">Text with Min and Max Length</label>
        <input type="text" id="minmaxlength" minlength="3" maxlength="12">
    </div>

    <div>
        <label for="password">Password (must contain at least 1 uppercase character, 1 lowercase character, and 1 number)</label>
        <input type="password" id="password" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" required>
    </div>

    <div>
        <label for="passwordwithtitle">Password with Title Attribute</label>
        <input type="password" id="passwordwithtitle" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" title="Please include at least 1 uppercase character, 1 lowercase character, and 1 number." required>
    </div>

    <div>
        <label for="passwordcombined">Password with Pattern and Min Length</label>
        <input type="password" id="passwordcombined" minlength="8" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" title="Please include at least 1 uppercase character, 1 lowercase character, and 1 number." required>
    </div>

    <input type="submit" class="button" value="Submit">
</form>

关于javascript - 显示具有特定 CSS 格式的警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56371584/

相关文章:

Javascript 变量不可见

javascript - 从图像的宽度和高度获取纵横比(PHP 或 JS)

javascript - 使用await作为参数

jquery - python:将嵌套字典转换为类似 JSON 的格式

javascript - 修改 w2ui 插件

javascript - Jquery 打印对象

javascript - 对于动态创建的复选框,单击事件处理程序不会持续存在

javascript - Array.prototype 导致错误

javascript - PHP MySQL 查询在实际提交的行之前插入 3 行(来自 w2ui 表)