新聞中心
如何在myeclipse中實現(xiàn)jquery的自動提示功能
方法如下:
創(chuàng)新互聯(lián)建站一直通過網(wǎng)站建設(shè)和網(wǎng)站營銷幫助企業(yè)獲得更多客戶資源。 以"深度挖掘,量身打造,注重實效"的一站式服務(wù),以成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、移動互聯(lián)產(chǎn)品、網(wǎng)絡(luò)營銷推廣服務(wù)為核心業(yè)務(wù)。10年網(wǎng)站制作的經(jīng)驗,使用新網(wǎng)站建設(shè)技術(shù),全新開發(fā)出的標(biāo)準(zhǔn)網(wǎng)站,不但價格便宜而且實用、靈活,特別適合中小公司網(wǎng)站制作。網(wǎng)站管理系統(tǒng)簡單易用,維護方便,您可以完全操作網(wǎng)站資料,是中小公司快速網(wǎng)站建設(shè)的選擇。
打開myeclipse,選擇windows--perferences--spket--javaScript Profiles,如下圖:
在右邊點擊new按鈕,進行新建,輸入名稱jquery,然后點擊確定,如下圖
然后選中jquery,點擊右側(cè)的”Add Library“按鈕,選擇”jQuery“
在選中”jQuery“,然后點擊右側(cè)的"Add File"按鈕,選擇之前下載的jquery.js
然后選中jquery,點擊右側(cè)的default按鈕,如下圖
找到General--Editors--File Accociations,然后將右側(cè)的js,關(guān)聯(lián)到Spket JavaScript Editor,將此編輯器設(shè)置為默認。如下圖
最終在myeclipse新建js文件,打開后,在里面寫入jquery代碼,出現(xiàn)自動提示,如下圖:
用jquery怎么驗證名字在輸入完之后馬上提示有沒有重復(fù)的代碼
1、給輸入名字的文本框綁定一個失去焦點事件,jquery中為focusout事件,同時在文本框后定義一個顯示檢查結(jié)果的span。
2、當(dāng)文本框失去焦點時,調(diào)用ajax異步向后臺發(fā)送請求。
3、將請求結(jié)果顯示在文本框后面提示用戶,避免所有信息填寫完畢表單提交時才發(fā)現(xiàn)名字重復(fù)。
示例:
input type='text' id='name'/span id='errorMsg'/erorMsg
//給文本框綁定一個失去焦點事件
$("#name").focusout(function() {
var name = $("#name").val();
if(name != null name != ''){
checkName(name);
}
});
//發(fā)ajax請求到后臺判斷用戶名是否重復(fù)
function checkName(name){
$.ajax({
url : servletUrl,
type : "post",
dataType : 'JSON',
data : {name:name},
success : function(result) {
//已經(jīng)存在該名字提示用戶
if(result == true){
$("#errorMsg").html("該用戶名已經(jīng)存在");
}else{
$("#errorMsg").html("恭喜您,用戶名可以使用");
}
}
},
error : function() {
alert('檢查用戶是否存在發(fā)生錯誤');
}
});
}
jquery怎么實現(xiàn)彈出提示框
JQuery的彈出提示框可以有兩種方式
Alert 方式以及 Confirm 方式彈出
Alert方式的彈出提示框,只能有一種抉擇,那就是確定,他這是一種不可選擇的提示
Confirm方式,是帶有選擇功能的提示框,用戶可以點擊確定或者取消
如何用jquery來做注冊提示信息
$('#regForm').validate({
rules:{
cellphone:{
required:true,
mobilephone:true,
remote:'/index/check-username'
},
verify:{
required:true,
remote:'/index/check-verifycode'
},
password:{
required:true,
minlength:6,
maxlength:20
},
confirmPassword:{
required:true,
minlength:6,
maxlength:20,
equalTo: "#password"
},
smgverifycode:{
required:true
},
/*inviteCode:{
maxlength:5,
minlength:5,
remote:"/index/check-invite-code"
},*/
agreement:{
required:true
}
},
messages:{
cellphone:{
required:addstyle('請輸入手機號碼'),
mobilephone:addstyle('不是有效的手機號'),
remote:addstyle('手機號碼已經(jīng)被注冊')
},
verify:{
required:addstyle('請輸入圖文碼'),
remote:addstyle('圖文碼不正確')
},
smgverifycode:{
required:addstyle('請輸入短信驗證碼')
},
password:{
required:addstyle('請輸入密碼'),
minlength:addstyle("密碼應(yīng)該為6-20位"),
maxlength:addstyle("密碼應(yīng)該為6-20位")
},
confirmPassword:{
required:addstyle('請再一次輸入密碼'),
minlength:addstyle("密碼應(yīng)該為6-20位"),
maxlength:addstyle("密碼應(yīng)該為6-20位"),
equalTo:addstyle('您輸入的確認密碼和密碼不一致')
},
/*inviteCode:{
maxlength: addstyle('邀請碼不正確'),
minlength: addstyle('邀請碼不正確'),
remote:addstyle('邀請碼不存在')
},*/
agreement:{
required:addstyle('請同意供貨商入駐協(xié)議')
}
},
errorElement:'p',
errorClass:'err_p',
errorPlacement:function(error, element){
if (e.html() == "" error[0].textContent != "") {
error.appendTo(e.show());
}
},
//success:function(label,element){
// console.log(2, label, element);
// label.parent().parent().siblings('div').removeClass('control-group err');
// if(label.text() == ''){
// label.parent().css('display','none');
// label.remove();
// }
//},
highlight: function (element) { // hightlight error input
if (e.find('p').attr('for') == 'smgverifycodeoften') {
e.html('').hide();
}
if (e.text() == "" || e.find('p').attr('for') == $(element).attr('id') ) {
$(element).parent().addClass('control-group err');
}
},
unhighlight: function (element) { // revert the change done by hightlight
var label = $("span.err_msg");
$(element).parent().removeClass('control-group err');
if(label.text() == '' e.text() == ""){
e.hide();
}
},
submitHandler:function(form){
s.addClass('alert-info').html('span注冊中...請稍后/span').show();
$.post("/index/post-register", $(form).serialize(), function(res){
if(res.code){
$.cookie('username', $('input[name="cellphone"]').val(), {expires:30});
s.html('span注冊成功, 跳轉(zhuǎn)至登錄頁.../span').show();
setTimeout(function(){
window.location = '/index/login';
}, 800);
} else {
s.hide(); //隱藏正確提示
/*if (res.data.reason == 1) {
$('#invite_code').parent().addClass('control-group err');
e.html('p for="invite_code" class="err_p"span class="err_msg"'+res.msg+'/span/p').show();//顯示錯誤信息
$(".err_p").show();
}*/
if (res.data.reason == 2) {
$('#smgverifycode').parent().addClass('control-group err');
e.show().html('p for="smgverifycode" class="err_p"span class="err_msg"'+res.msg+'/span/p');//顯示錯誤信息息
$(".err_p").show();
} else {
$('#smgverifycode').parent().addClass('control-group err');
e.show().html('p for="smgverifycode" class="err_p"span class="err_msg"'+res.msg+'/span/p');//顯示錯誤信息息
$(".err_p").show();
}
setTimeout(function() {
e.hide().html('')
}, 2000);
}
},'json');
}
});
});
網(wǎng)站題目:jquery提示信息,jQuery提示信息
分享網(wǎng)址:http://www.dlmjj.cn/article/dsdsghc.html