如果用户没有从自动列表中选择任何值,则不提交 [英] Shuoldn't submit if user didn't select any value from auto list

查看:55
本文介绍了如果用户没有从自动列表中选择任何值,则不提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好今天的问候我给了我的代码和我的问题请解决这个问题,



我的问题是:

这里我为用户提供自动列表。如果用户输入类似S的值,则自动列表会显示以S开头的所有值,但是用户没有从自动列表中选择值并且n单击(值为s) )然后在表格中插入按钮用S.保存值。



这里我的要求是用户是否没有从自动列表中选择任何值(即使是一个值S或者等等)然后得到一个警报我选择任何值....当点击插入按钮。



我的代码是:

Hi greetings of the day here i gave my code and my problem please resolve this,

my problem is:
Here i'm providing a auto list to the user.If the user enter a value like S then the auto list shows all the values starting with S,but user didn't select value from the auto list and n click (with the value of s) insert button then in the table save the value with S.

Here my requirement is if user didn't select any value from the auto list( even a value with S or etc) then get a alert my select any value....when click the insert button.

my code is :

$("#txtCountry").autocomplete({
source: function (request, response) {
var x = $('#txtCountry').val();
$.ajax({
url: "/abc/xyz",
type: "POST",
dataType: "json",
data: { term: x },
success: function (data) {
response($.map(data.countrylist, function (item, r) {
debugger
return {
label: item
}
}));
},
messages: {
noResults: "", results: ""
},
}
},
minLength: 1
})
}
});
});



in insert botton



country = $('#txtCountry') .val(); //这里的值是cary但我的要求是用户没有选择任何值然后它应该是空的。


in insert botton

country = $('#txtCountry').val();//here value is cary but my requirement is user didn't select any value then it should be empty.

if (country == "") {
alert("required");
return false;
}



帮我解决这个问题。



我上次与此斗争6小时。


help me to resolve this.

i'm fighting with this from last 6 hours.

推荐答案

#txtCountry)。autocomplete({
source: function (request,response){
var x =
("#txtCountry").autocomplete({ source: function (request, response) { var x =


' #txtCountry' ).val();
('#txtCountry').val();


.ajax({
url: / abc / xyz
类型: POST
dataType: json
data:{term:x},
成功:功能(数据){
回复(
.ajax({ url: "/abc/xyz", type: "POST", dataType: "json", data: { term: x }, success: function (data) { response(


这篇关于如果用户没有从自动列表中选择任何值,则不提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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