2012-02-29 7 views
1

これは私のフォームと検証jQueryですが、UIのこのファイルをアップロード(倍数)に表示すると、「3文字以内で入力してください。私は問題がファイルフィールドのmaxlength="3"プロパティだと思う。jqueryの検証でフィールドファイルを無視します

このフィールドの検証をどのように削除しますか?

 <table cellpadding="0" cellspacing="0" class="main_table"> 
       <tr> 
        <td class="label">@Resources.Registo.nome</td> 
        <td>@Html.TextBox("FullName", (Model != null ? Model.FullName : string.Empty), new { @class = "width250" }) 
         @Html.ValidationMessageFor(model => model.FullName)</td> 
       </tr> 
       <tr> 
        <td class="label">@Resources.Registo.email</td> 
        <td>@Html.TextBox("Email", (Model != null ? Model.Email : string.Empty), new { @class = "width250" }) 
         @Html.ValidationMessageFor(model => model.Email)</td> 
       </tr> 
       <tr> 
        <td class="label">@Resources.Registo.exemploFotos</td> 
        <td><input type="file" name="fileUpload" class="multi" accept="jpeg|jpg" maxlength="3" /></td> 
       </tr> 

       <tr><td colspan="2"><a class="button" onclick="$('#FormToValidate').valid() == true ? get_form(this).submit() : false" id="validateAndSubmitBtn" ><span>@Resources.Global.btnSubmit</span></a></td></tr> 
     </table> 



$().ready(function() { 
     // validate signup form on keyup and submit 
     $("#FormToValidate").validate({ 

      rules: { 

       FullName: { 
        required: true 
       }, 
       Email: { 
        required: true, 
        email: true 
       } 
      }, 
      messages: { 
       FullName: { 
        required: "@Resources.Registo.requiredFullName" 
       }, 
       Email: { 
        required: "@Resources.Registo.requiredEmail", 
        email: "@Resources.Registo.emailValid" 
       } 
      } 
     }); 

    }); 
+0

ホイール私はこれを回避するために回避策をとっています(私はfileUpload maxlenght = "" – AFetter

答えて

2

ignoreパラメータを試してみてください:あなたが選ぶべき

$("#FormToValidate").validate({ 
    rules: { 
     FullName: { 
      required: true 
     }, 
     Email: { 
      required: true, 
      email: true 
     } 
    }, 
    messages: { 
     FullName: { 
      required: "@Resources.Registo.requiredFullName" 
     }, 
     Email: { 
      required: "@Resources.Registo.requiredEmail", 
      email: "@Resources.Registo.emailValid" 
     } 
    }, 
    ignore: "input[type='file']" 
}); 

あなたはパラメータに任意の有効なjQueryのセレクタを使用することができます。

+0

nopsのメンテナンスを行います。これは動作しません)。 – AFetter

+0

私の場合でもうまくいきません..... –

+0

@SwapnilChincholkarあなたはこれに対する解決策を見つけましたか? –

関連する問題