如何設置聯繫人表格7插件的文本字段以僅允許某些字符? 我希望這個字段只接受被認爲是特殊字符的希臘字符。 有沒有辦法爲此添加24個字符?聯繫表格7只接受某些字符
0
A
回答
0
這很可能是可能的,因爲其他人已經表明可以定製它。
先註冊你的回調方法:
//add fiter for text area validation
add_filter('wpcf7_validate_textarea', 'cf7_custom_textarea_validation', 10, 2);
add_filter('wpcf7_validate_textarea*', 'cf7_custom_textarea_validation', 10, 2);
而且回調裏面,做您的驗證:
function cf7_custom_form_validation($result, $tag)
{
$type = $tag['type'];
$name = $tag['name'];
$value = $_POST[$name];
...
if ($type == 'yourtype*' && !preg_match($your_regex, $value)) {
$result['valid'] = false;
$result['reason'][$name] = __('message for your regex not matching');
}
...
看到這裏exemplare代碼:
這裏閱讀示範性的博文:
聯繫從7的支持,請訪問:http://wordpress.org/support/plugin/contact-form-7
你找到http://codex.wordpress.org/記錄所有的WordPress API函數。
0
聯繫表7的版本4.5.1 一切 PHP相關的記錄。它爲我工作。
//code to validate textbox
function custom_text_validation_filter($result, $tag) {
$type = $tag['type'];
$name = $tag['name'];
//here textbox type name is 'subject'
if($name == 'subject') {
$value = $_POST[$name];
if (preg_match('/[\'^£$%&*()}{@#~><>|=_+¬]/', $value)){
$result->invalidate($tag, "Invalid characters.");
}
}
return $result;
}
add_filter('wpcf7_validate_text','custom_text_validation_filter', 10, 2);
add_filter('wpcf7_validate_text*', 'custom_text_validation_filter', 10, 2);
//code to validate textarea
function custom_textarea_validation_filter($result, $tag) {
$type = $tag['type'];
$name = $tag['name'];
//here textarea type name is 'message'
if($name == 'message') {
$value = $_POST[$name];
if (preg_match('/[\'^£$%&*()}{@#~><>|=_+¬]/', $value)){
$result->invalidate($tag, "Invalid characters.");
}
}
return $result;
}
add_filter('wpcf7_validate_textarea','custom_textarea_validation_filter', 10, 2);
add_filter('wpcf7_validate_textarea*', 'custom_textarea_validation_filter', 10, 2);
相關問題
- 1. MPDF將不接受某些字符
- 2. WinForms MaskedTextBox接受某些字符
- 3. 接受的方法只有某些字符串在C#
- 4. 從plist中讀入,但只接受某些字符串
- 5. 如何只接受一個字符串與Java中的某些字符
- 6. 在只讀輸入字段設置值聯繫表格7 WordPress
- 7. JavaScript在聯繫表格7
- 8. 聯繫表格7驗證
- 9. 聯繫表格7問題
- 10. 使接受某些字符的正則表達式
- 11. 正則表達式/ NG模式接受某些字符
- 12. 只允許某些字符
- 13. 聯繫表單不接受希臘字符
- 14. WordPress的 - 聯繫表格7不發送到某些電子郵件
- 15. 如何:文本字段只接受某些單詞
- 16. 接受某些答案
- 17. 聯繫表格中的特殊字符
- 18. 聯繫表格特殊字符
- 19. 聯繫表格土耳其字符
- 20. ZF2翻譯只接受內聯字符串而不接受Php變量
- 21. Wordpress聯繫表7
- 22. Bootstrap聯繫表7
- 23. 聯繫表7(wordpress)
- 24. 聯繫表格7 +貝寶集成
- 25. 聯繫表格7 on_submit不起作用
- 26. JavaScript的衝突:聯繫表格7 superfish.js
- 27. wordpress聯繫表格-7附件問題
- 28. 聯繫表格7現場標籤
- 29. 聯繫表格7(WordPress的插件)
- 30. 聯繫表格7簡碼到陣
'聯繫表格7'與正則表達式有什麼關係? – sln