0

バリデーション付きの XFBML フォームを作成しました。エンド ユーザーにとってオプションのフィールドがいくつかあります。ただし、検証が有効になるとすぐに、フォームはすべてのフィールドが入力されることを期待します。したがって、オプションのフィールドに必要な検証をスキップする方法。

コードは現在次のようになっています。

<fb:registration redirect-uri="http://www.sakshum.org/FbBloodDonorRegister" fields='[{"name":"name"},{"name":"first_name"},{"name":"last_name"}, {"name":"gender"}, {"name":"birthday"},{"name":"email"}, {"name":"cellPhone", "description":"Cell Number", "type":"text"}, {"name":"homePhone", "description":"Home Number", "type":"text"}, {"name":"officePhone", "description":"Office Number", "type":"text"}, {"name":"primaryAddress", "description":"Primary Address", "type":"text"}, {"name":"area", "description":"Locality/Village/Area", "type":"text"},{"name":"location"}]'  onvalidate="validated" width="530">
</fb:registration>
<script> 
function validated(form) {
    errors = {};    
    if(form.cellPhone.trim().length != 10){
        errors.cellPhone = "Cell number is required and should be 10 of digits";
    }

    if(form.homePhone.trim().length > 0){
        if(form.homePhone.trim().length != 10)
            errors.homePhone = "Home number should be 10 of digits";
    }   

    if(form.officePhone.trim().length > 0){
        if(form.officePhone.trim().length != 10)
            errors.officePhone = "Office number should be 10 of digits";
    }   

    if(form.homePhone.trim().length > 0 || form.officePhone.trim().length > 0){
        if(form.homePhone.trim() == form.officePhone.trim() || form.homePhone.trim() == form.cellPhone.trim() || form.officePhone.trim() == form.cellPhone.trim()){
            errors.homePhone = "Cell number, office number and home number cannot be same";
            errors.officePhone = "Cell number, office number and home number cannot be same";
        }
    }

  return errors;
}
</script> 
4

1 に答える 1

0

Facebook の既知のバグのように見えます https://developers.facebook.com/bugs/139030226234017?browse=search_50551341bcf073b68986277

于 2012-09-15T23:48:48.923 に答える