2014-10-29 132 views
0

我使用的聯繫表格7插件,我想大約有文字box.So邊境,我已經改變了script.js這是includes>JS文件夾周圍輸入字段邊界。聯繫表7驗證:

前:

$.fn.wpcf7NotValidTip = function(message) { 
     return this.each(function() { 
      var $into = $(this); 

      $into.find('span.wpcf7-not-valid-tip').remove(); 
      $into.append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>'); 
      if ($into.is('.use-floating-validation-tip *')) { 
       $('.wpcf7-not-valid-tip', $into).mouseover(function() { 
        $(this).wpcf7FadeOut(); 
       }); 

       $(':input', $into).focus(function() { 
        $('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut(); 
       }); 
      } 
     }); 
    }; 

後:

$.fn.wpcf7NotValidTip = function(message) { 
     return this.each(function() { 
      var $into = $(this); 

      $into.find('span.wpcf7-not-valid-tip').remove(); 
      $into.append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>'); 
      $into.find(':input').css('border-color', 'red');//it will add red color border 
      if ($into.is('.use-floating-validation-tip *')) { 
       $('.wpcf7-not-valid-tip', $into).mouseover(function() { 
        $(this).wpcf7FadeOut(); 
        $into.find(':input').removeAttr('style'); //for removing red color 
       }); 

       $(':input', $into).focus(function() { 
        $('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut(); 
        $into.find(':input').removeAttr('style');//for removind red color 
       }); 
      } 
     }); 
    }; 

問題:在驗證的時候它顯示validation.But我填補了該領域,它應該刪除邊框顏色。所以,一旦我填滿了所有的東西,我怎麼能去掉那種顏色。所以任何人都可以告訴我我錯過了什麼或者應該添加什麼?

+1

爲什麼人們更感興趣的是唐氏票,而不是給解決方案? 我的問題很清楚,我想要達到的目標,我也提供了代碼.. – Twix 2014-10-29 08:09:18

+0

爲什麼編輯.js?你不能用css改變邊框嗎? ''border','box-shadow'和'outline'是查看輸入邊框等的主要'元兇'... – 2014-10-29 08:45:46

+0

@Rohil_PHPBeginner這是什麼意思? – Twix 2014-10-29 09:10:53

回答

2

通過插件裏面打了將近一個小時後,找到了解決辦法。

您正在刪除您的風格錯誤的地方

$.fn.wpcf7NotValidTip = function(message) { 
    return this.each(function() { 
     var $into = $(this); 

     $into.find('span.wpcf7-not-valid-tip').remove(); 
     $into.append('<span role="alert" class="wpcf7-not-valid-tip">' + message + '</span>'); 
     $into.find(':input').css('border-color', 'red');//it will add red color border 
     if ($into.is('.use-floating-validation-tip *')) { 
      $('.wpcf7-not-valid-tip', $into).mouseover(function() { 
       $(this).wpcf7FadeOut(); 
       //removed this line from your code 
      }); 

      $(':input', $into).focus(function() { 
       $('.wpcf7-not-valid-tip', $into).not(':hidden').wpcf7FadeOut(); 
       //removed this line from your code 
      }); 
     } 
    }); 
}; 

您需要刪除你的風格在wpcf7ClearResponseOutput此功能:

$.fn.wpcf7ClearResponseOutput = function() { 
     return this.each(function() { 
      $(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked').removeAttr('role'); 
      $(this).find('span.wpcf7-not-valid-tip').remove(); 
      $(this).find(':input').removeAttr('style'); //here I have added those lines for removing style 
      $(this).find('img.ajax-loader').css({ visibility: 'hidden' }); 
     }); 
    }; 

希望工程爲you.Great任務對我來說:)

+0

哇!你在短短的一小時內就能管理好,並且我嘗試了5個小時:) 它像gem.Thanks :) – Twix 2014-10-29 12:22:33