如何验证文本框以避免使用jquery的空框 [英] How to validate text box in order to avoiding empty box using jquery

查看:67
本文介绍了如何验证文本框以避免使用jquery的空框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我点击提交按钮时,txtbox都包含一些内容,如果我在txtbox为空时提交按钮,则提示文本框的文本不为空,文本框值也是唯一的(避免重复)数据库中



我尝试过:



html









Features_Name:







javascript



$(document).ready(function( ){

$('。submit')。attr('disabled',true);

$('#txtName')。keyup(function(){

if($ .trim($(this).val.length!= 0)){

$('。submit')。attr('disabled',false );

}

else if($ .trim($('#txtName')。val.length ==0)){

alert('Features_Name不为空');

}

else {

$('。submit')。attr('disabled',true);

}



})

})

whenever i clicked the submit button the txtbox contains something in that,if i submit the button when txtbox is empty alert will come with text of text box is not empty and also textbox values are unique (avoiding duplicates) in the database

What I have tried:

html




Features_Name:



javascript

$(document).ready(function () {
$('.submit').attr('disabled', true);
$('#txtName').keyup(function () {
if ($.trim($(this).val.length != 0)) {
$('.submit').attr('disabled', false);
}
else if ($.trim($('#txtName').val.length =="0")) {
alert('Features_Name is not empty');
}
else {
$('.submit').attr('disabled', true);
}

})
})

推荐答案

(文件).ready(function( ){
(document).ready(function () {


('。submit')。attr('disabled',true);
('.submit').attr('disabled', true);


(' #txtName')。keyup(function(){

if(
('#txtName').keyup(function () {
if (


这篇关于如何验证文本框以避免使用jquery的空框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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