2011-09-03 135 views
0

我有這樣的名字,這些表單字段:Java的HTML表單的輸入名稱

/dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName

其中進出口試圖進入jQuery的驗證,但得到各種各樣的錯誤。有人有建議嗎?

$("#temp2_form").validate({ 
    rules: { 
     email: { 
     required: true, 
     email: true 
     }, 
     /dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName: { 
     required: true 
     }  
    } 
    }); 

回答

1

這是因爲.在JavaScript中有特殊含義。幸運的是,只需使用字符串查找而不是直接分配即可修改。試試:

// you might also want to get the name attribute from the element itself 
var firstName = '/dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName' 

var validRules = { 
    rules: { 
    email: { 
     required: true, 
     email: true 
    } 
    } 
} 

validRules[firstName]={required:true} 
$("#temp2_form").validate(validRules)