html
<input id="labt1" type="radio" name="LABTYPE" name="LAB" value="1" >LAB1
<input id="labt2" type="radio" name="LABTYPE" name="LAB" value="2" >LAB2
--------------------------------------------
JavaScript
if(typeof($("input[name=LABTYPE]:checked").val()) === "undefined" )
{
alert("請選擇LAB");
return false;
}
2015年3月25日 星期三
jQuery : 判斷html text不可空白 (check html input tag value not null)
html
<form id="FROMTAG" name="form1" method="post">
<input type="text">
----------------------------------------------------------------
JavaScript
$("#FROMTAG").find(':input').each(function()
{
var ty = this.type;
var val = $(this).val();
if(ty=="text" && val=="")
{
alert("欄位不可空白");
return false;
}
});
<form id="FROMTAG" name="form1" method="post">
<input type="text">
----------------------------------------------------------------
JavaScript
$("#FROMTAG").find(':input').each(function()
{
var ty = this.type;
var val = $(this).val();
if(ty=="text" && val=="")
{
alert("欄位不可空白");
return false;
}
});
2015年3月24日 星期二
jQuery : Ajax html
var div
var organ
$.ajax({
url: '/html/text/pages/Mean.jsp',
dataType: 'html',
type:'POST',
async:false,
data: { No: div, Size: organ },
error: function(xhr) {
alert('Ajax request 發生錯誤');
},
success: function(response) {
$("#ID").html($.trim(response));
}
});
var organ
$.ajax({
url: '/html/text/pages/Mean.jsp',
dataType: 'html',
type:'POST',
async:false,
data: { No: div, Size: organ },
error: function(xhr) {
alert('Ajax request 發生錯誤');
},
success: function(response) {
$("#ID").html($.trim(response));
}
});
2014年11月13日 星期四
jQuery: checkbox readonly
readonly :
$(":checkbox").click(function(e){ e.preventDefault(); });
remove readonly :
$(":checkbox").unbind('click');
$(":checkbox").click(function(e){ e.preventDefault(); });
remove readonly :
$(":checkbox").unbind('click');
2013年2月18日 星期一
jQuery : ajax解決中文亂碼
$.ajax({
url: ' ',
dataType: 'html',
type:'POST',
async:false,
// 解決中文亂碼
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
data: {
},
error: function(xhr) {
},
success: function(response) {
}
});
訂閱:
文章 (Atom)