html - 如何验证 Materialise 下拉菜单的选择选项?

标签 html materialize

我有一个使用 materializecss 的基本选择框。

<select id="type" name="type" required="required" class="validate">
    <option value="" disabled="true" selected="selected">Choose your option</option>
    <option value="general">General</option>
    <option value="tech">Tech</option>
    <option value="person">Personnel</option>
    <option value="resource">Resourcing</option>
</select>
<label data-error="Select an option">Type of Question</label>

我希望用户在能够提交表单之前选择一个选项。

如果用户没有选择选项,我如何让它显示标签的 data-error

最佳答案

$("select[required]").css({display: "block", height: 0, padding: 0, width: 0, position: 'absolute'});

关于html - 如何验证 Materialise 下拉菜单的选择选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34248898/

相关文章:

javascript - 如何禁用指针事件,但允许拖动

javascript - Webpack加载materialize-css,无法读取未定义的属性 'swing'

html - 将 <td> 的值添加到文本框 onclick 时遇到问题

javascript - 按顺序获取数组中的项目然后重复?

javascript - 如果我动态更改 html 内容,如何保持 CSS 样式?

html - 加载背景图像但仅显示其中两个

html - 在另一个图像上实现图像

javascript - 如何动态地用文本输入替换物化选择?

asp.net - 如何在不对其名称进行硬编码的情况下引用主域?

javascript - 原生 HTMLElement 属性观察器