|
|
|
มีใครเคยใช้ varlidate ของ bootstrap มั้ยคับ ดูน่าใช้มากๆ แต่มันไม่ varlidate ให้อ่า |
|
|
|
|
|
|
|
HTML
Code (PHP)
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<input name="test" type="text" placeholder="Type something…"/>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
Code (JavaScript)
$("form").validate({
rules: {
test: {
minlength: 3,
required: true
}
},
showErrors: function(errorMap, errorList) {
$.each(this.successList, function(index, value) {
return $(value).popover("hide");
});
return $.each(errorList, function(index, value) {
var _popover;
console.log(value.message);
_popover = $(value.element).popover({
trigger: "manual",
placement: "top",
content: value.message,
template: "<div class=\"popover\"><div class=\"arrow\"></div><div class=\"popover-inner\"><div class=\"popover-content\"><p></p></div></div></div>"
});
_popover.data("popover").options.content = value.message;
return $(value.element).popover("show");
});
}
});
ตัวอย่าง http://jsfiddle.net/3qYpM/2/
Tag : PHP
|
|
|
|
|
|
Date :
2013-06-06 10:04:05 |
By :
mrronalz |
View :
1596 |
Reply :
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เข้ามาแล้วคับ แต่ัมันก็ไม่ได้คับ
|
|
|
|
|
Date :
2013-06-06 10:34:29 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก็ได้นี่ครับ
Code
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
</head>
<script>
$(document).ready(function() {
$("form").validate({
rules: {
test: {
minlength: 3,
required: true
}
},
showErrors: function(errorMap, errorList) {
$.each(this.successList, function(index, value) {
return $(value).popover("hide");
});
return $.each(errorList, function(index, value) {
var _popover;
console.log(value.message);
_popover = $(value.element).popover({
trigger: "manual",
placement: "top",
content: value.message,
template: "<div class=\"popover\"><div class=\"arrow\"></div><div class=\"popover-inner\"><div class=\"popover-content\"><p></p></div></div></div>"
});
_popover.data("popover").options.content = value.message;
return $(value.element).popover("show");
});
}
});
});
</script>
<body>
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<input name="test" type="text" placeholder="Type something…"/>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</body>
</html>
|
ประวัติการแก้ไข 2013-06-06 10:47:20
|
|
|
|
Date :
2013-06-06 10:46:58 |
By :
t-monroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆๆๆๆๆคับ
ขอสอบถามหน่อยคับ มีข้อสงสัย แบบถ้าผมจะทำเป็นตอนสมัครสมาชิก
แล้วใส่ password กับ confirm password จะสามารถทำให้มันเช็คค่าได้มั้ยคับว่าสองตัวนี้เท่ากัน
|
|
|
|
|
Date :
2013-06-06 11:36:33 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
</head>
<script>
$(document).ready(function() {
$("form").validate({
rules: {
test: {
minlength: 3,
required: true
},
password: {
minlength: 5,
required: true
},
password_confirm: {
minlength: 5,
equalTo: "#password"
}
},
showErrors: function(errorMap, errorList) {
$.each(this.successList, function(index, value) {
return $(value).popover("hide");
});
return $.each(errorList, function(index, value) {
var _popover;
console.log(value.message);
_popover = $(value.element).popover({
trigger: "manual",
placement: "top",
content: value.message,
template: "<div class=\"popover\"><div class=\"arrow\"></div><div class=\"popover-inner\"><div class=\"popover-content\"><p></p></div></div></div>"
});
_popover.data("popover").options.content = value.message;
return $(value.element).popover("show");
});
}
});
});
</script>
<body>
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<input name="test" type="text" placeholder="Type something…"/>
<input name="password" type="text" placeholder="Password"/>
<input name="password_confirm" type="text" placeholder="Confirm"/>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</body>
</html>
|
ประวัติการแก้ไข 2013-06-06 11:49:41
|
|
|
|
Date :
2013-06-06 11:48:34 |
By :
t-monroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรง confirm password ลองใส่ไปแล้วคับ แต่มันบอกให้ใส่ให้เหมือนกันน่ะคับ งงเลย
|
|
|
|
|
Date :
2013-06-06 12:24:48 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ๋อ เจอแล้วคับ ตรง
Code (PHP)
<input name="password" type="text" placeholder="Password"/>
ไม่มีค่า id คับ
|
|
|
|
|
Date :
2013-06-06 12:26:44 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณอีกครั้งคับ
|
|
|
|
|
Date :
2013-06-06 12:27:05 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|