Monthly Archives: December 2008

Generate data

Trước đây từng hơi bí với việc test performance với lượng dữ liệu lớn vì phía khách hàng họ “gợi ý” là dữ liệu tuy là để test nhưng cũng phải “đẹp” nữa, và họ không thích kiểu tên nhân viên có dạng như: employee 1, employee 2…

Hôm qua chả hiểu lang thang thế nào lại lạc vào trang Generatedata.com :D Quả thật là chỉ riêng việc họ cho mình 5 tùy chọn result type (HTML , Excel, XML, CSV, SQL) mình đã hạnh phúc lắm rồi :X ấy thế mà họ còn cho mình free download, không kèm bất cứ quảng cáo gì hay trail gì cả /:D/

Quá tuyệt >:D<

Accept only positive number using Jquery

Có thể sử dụng Event Handling hoặc Event Helper. Tất nhiên là sử dụng Event Helper thì ngắn hơn rồi :)

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
//when key is pressed in the textbox
$("#quantity").keypress(function (e)
{
  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    $("#errmsg").html("Digits Only").show().fadeOut("slow");
    return false;
  }
});

Mình quen viết thế này hơn:

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
//when key is pressed in the textbox
$("#quantity").keypress
(
    function (e) {
        //if the letter is not digit then display error and don't type anything
        if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) {
            //display error message
            $("#errmsg").html("Digits Only").show().fadeOut("slow");
            return false;
        }
    }
);

Nguồn: http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html