下面是当文本字段为空时发出警报的代码。我想通过替换alertbox来突出显示名为education的文本字段。
$(document).ready(function() {
$('#update').click(function() {
if (!$.trim($('#education').val())) {
alert("Please select education");
}
});
});发布于 2016-11-02 17:48:57
$(document).ready(function() {
$('#update').blur(function() {
if ($('#education').val() == "" || $('#education').val()==null) {
$("input").focus(function(){
$("#education").css("border-style", "solid").css(" border-color","#ff0000");
});
}
});
});发布于 2016-11-02 17:51:58
试试这个:
$(document).ready(function() {
$('#update').click(function() {
if (!$.trim($('#education').val())) {
//alert("Please select education");
$('#education').focus();
}
});
});发布于 2016-11-02 17:57:36
您可以尝试类似以下内容的方法
$("input[name='education']").select();这会将光标放在文本字段中。您还可以添加一个类,如下所示
$("input[name='education']").select().addClass("warning");并将.warning样式设置为更粗体,以突出显示问题所在
https://stackoverflow.com/questions/40376368
复制相似问题