便當盒

  • Random
  • Archive
  • RSS
  • Ask me anything

jQuery Validation - fix required method not work in ie8.

由於個人使用 required 驗證的方式是這樣的:

<input .... required="required" />

但在 IE8 中,depend() 裡的 typeof param 會是 string 而非預期的 boolean。必須在 required() 裡面加上這段才會正常:

if ( $.browser.msie ) {
    param = param === 'required';
}

加在 this.depend() 呼叫之前:

required: function(value, element, param) {
    if ( $.browser.msie ) {
        param = param === 'required';
    }
    // check if dependency is met
    if ( !this.depend(param, element) )
        return "dependency-mismatch";
    switch( element.nodeName.toLowerCase() ) {
    case 'select':
        // could be an array for select-multiple or a string, both are fine this way
        var val = $(element).val();
        return val && val.length > 0;
    case 'input':
        if ( this.checkable(element) )
            return this.getLength(value, element) > 0;
    default:
        return $.trim(value).length > 0;
    }
},
    • #jquery
    • #validation
  • 5 months ago
  • 15
  • Comments
  • Permalink
  • Share
    Tweet

15 Notes/ Hide

  1. buttononde liked this
  2. bachelor231 liked this
  3. determinesek6 liked this
  4. pictures810 liked this
  5. qualityer9 liked this
  6. disabilitiesfg59 liked this
  7. emileeyou89 liked this
  8. yeseniauio09 liked this
  9. brendaca83 liked this
  10. francesuy56 liked this
  11. nickthejam liked this
  12. nahoya posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Avatar

Me, Elsewhere

  • @BeataLyn on Twitter
  • Facebook Profile
  • Google
  • beata on github

Twitter

loading tweets…

Following

I Dig These Posts

See more →
  • Photoset via sonic1993


    this is Deth-Chu in order Nathan-chu, Toki-chu, Swis-chu, Pickles-chu, Murder-chu

    Photoset via sonic1993
  • Post via evenwu
    要求手繪 Logo 字體的迷思

    這是一個 logo 設計上的迷思,我常常聽到客戶要求:

    不要使用市面上的字體,那會跟別人一樣,我要「完全手繪的字體」。

    透過長年的訪談結果,他們的迷思通常是:

    • 字體好貴
    • 現成的字體會跟別人一樣

    ...

    Post via evenwu
  • Post via vincicat
    heroku 的 custom domain 與 Google App (on namecheap)

    heroku的DNS其實有點麻煩。

    因為Official給的”proxy.heroku.com.” (CNAME) 是不能設在 “@” (naked hostname) 上的…設了的話...

    Post via vincicat
  • Post via vincicat
    Bootstrap神器

    Twitter Bootstrap很強大大家都知道的吧。隨著Bootstrap的人氣也有不少Tool去支援:

    • 針對Bootstrap的Icon Font FontAwesome
    • Theme Bootswatch.com
    • Button...
    Post via vincicat
  • Link via jiwostudio
    "How do I go back?"

    Chris Pirillo 的爸爸使用 Windows 8 的情形。

    幸好我爸是用 iPad 的。

    4 分 13 秒左右:

    Who puts this out?

    Microsoft.

    They’re trying to drive me to...

    Link via jiwostudio
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

創用 CC 授權條款 本著作係採用創用 CC 姓名標示-相同方式分享 3.0 Unported 授權條款授權 - . Effector Theme by Carlo Franco.

Powered by Tumblr