แสดงบทความที่มีป้ายกำกับ jQuery แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ jQuery แสดงบทความทั้งหมด

วันศุกร์ที่ 4 พฤษภาคม พ.ศ. 2555

Jquery Input Number Validation

$(document).ready(function() {
    $("#txtboxToFilter").keydown(function(event) {
        // Allow: backspace, delete, tab, escape, and enter
        if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || 
             // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) || 
             // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                 // let it happen, don't do anything
                 return;
        }
        else {
            // Ensure that it is a number and stop the keypress
            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
                event.preventDefault(); 
            }   
        }
    });
});
 
For number only
and this option for this.
support decimal format : 
event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 190
 
This ref is here
http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery
 






วันจันทร์ที่ 19 มีนาคม พ.ศ. 2555

MVC Jquery Json return internal 500

When use getJSON and call Action result correct but response internal 500

This is because json not allow get type (Only post can do.)
fix this is simple by

return this.Json( list, JsonRequestBehavior.AllowGet );

The key is AllowGet for can call function simple.

วันพฤหัสบดีที่ 15 มีนาคม พ.ศ. 2555

MVC3 and Uploadify Problem IO/HTTP Error

It work well if you not check authorize on controller
but it will not work if used authorize because uploadify use flash to upload.

for work around check on this post

http://stackoverflow.com/questions/8948000/mvc-3-uploadify-http-302-error
http://stackoverflow.com/questions/8358223/getting-http-error-while-using-uploadify-on-asp-net-mvc-application
http://stackoverflow.com/questions/3791724/getting-uploadify-to-work-with-asp-net-mvc
http://www.leftandmain.com/silverstripe-tips/2011/02/15/uploadify-http-error-explained-and-solved-maybe/
http://zootfroot.blogspot.com/2010/12/mvc-file-upload-using-uploadify-with.html

not sure if what the best solution but first and the second is the same.
I not write content here because i want to get rid flash from my project  for now this is temporary for use flash in my project.

Hope this help.

วันอังคารที่ 25 พฤษภาคม พ.ศ. 2553

Greasemonkey and JQuery

I try to @require http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.js
but it fail

so after search found if use full version (min version will get another error.)
we must change some in jquery code in line by used try catch to avoid error

isSupported = (eventName in el);
if ( !isSupported ) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
el = null;

to

try {
isSupported = (eventName in el);
if ( !isSupported ) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
el = null;
} catch(e) {}

now it work.

and another notice require will load only once when install user script to grease monkey so if you edit it it will need to uninstall and install again

to install new script is easy drag and drop your script to browser.

and you got lasted script by

http://www.asp.net/ajaxlibrary/cdn.ashx

วันอาทิตย์ที่ 28 มีนาคม พ.ศ. 2553

jQuery and error "$ is not define"

To day I use Jquery in ASP.NET MVC and can't make it work.
It's always show java script error about "$ is not defined"

Yes after search and found a call wrong path for Include my jQuery script

and my problem now is confuse about relative path for jquery in my master page

and finally anything solve by

Url.Content ("~/Scripts/jquery-1.3.2.min.js")

Used this instead of

../../Scripts/jquery-1.3.2.min.js

Yes I don't include full code here because Google don't support code html for example with out encoding it myself.

I will find another block for do that.

Yes this will solve problem with css too.