Tuesday, March 22, 2011

Form Login with Validate




<script type="text/javascript" src="<?= base_url();?>system/application/js/jquery.js"></script>
<script type="text/javascript" src="<?= base_url();?>system/application/js/jquery.validate.js"></script>



<style type="text/css">
label.error {
color: red;
font-style: italic
}
div.error { display: none; }
</style>



<script type="text/javascript">
$(document).ready(function(){
//Validate
$("#Cform").validate({
rules: {
username: { required : true },
password: { required : true}
},
messages: {
username: { required : "โปรดระบุชื่อผู้ใช้" },
password: { required : "โปรดระบุรหัสผ่าน"}
}});

$("#Cform").validate();

});
</script>




<?
$attributes = array( 'calss' => 'cmxform', 'id'=> 'Cform');
echo form_open("authen/login", $attributes)?>
<table style="padding:10px; margint:10px; font-size:20px" cellpadding=5>
<tr>
<td> ชื่อผู้ใช้</td>
<td> <input type="text" name="username" id="username" style="font-size:20px; color:orange"></td>
</tr>
<tr>
<td>รหัสผ่าน</td>
<td><input type="password" name="password" id="password" style="font-size:20px; color:orange"></td>
</tr>
<tr>
<td colspan=2> <center><input type="submit" value="Login"></center></td>

</tr>
</table>
</form>

Thursday, December 30, 2010

Watermark Plugin




Reference :: http://digitalbush.com/projects/watermark-input-plugin/

JQuery Script แสดง notice แบบลายน้ำ เมื่อจะคีย์ข้อมูลลงไปลายน้ำจะหายไป
##Include

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="watermarkinput.js"></script>

##Javascript

jQuery(function($){
$("#chat").Watermark("What's on your mind?");
});

##HTML

<input type="text" id="chat" >

Tuesday, October 5, 2010

Checkbox ( tick all/ untick all )

ใช้บ่อย

$('#id_checkbox_checkall').click(function(){
var all = $('#id_checkbox_checkall').is(':checked');
if(all){
$(".class_checkbox").attr('checked', true);
}else{
$(".class_checkbox").attr('checked', false);
}
});