2015年5月5日 星期二

jquery validate plugin

            $("#form1").validate({
                debug: true,
                rules: {
                    submitHandler: function (form1) {
                        $("#send").attr("disabled", true);
                        $("#d1").attr('class', "center disable");
                        form1.ajaxSubmit();
                    },
                    LOGIN_ID: {
                        required: true,
                        remote: {
                            url: "AccountAPI.aspx",
                            type: "POST",
                            dataType: "json",
                            data: {
                                uid: function () {
                                    return $("#LOGIN_ID").val();
                                },
                                API: "ismemberidavailable",

                            },
                            dataFilter: function (data) {
                                var x = (JSON.parse(data)).state;
                                if (x == "true") {
                                    return '"true"';
                                }
                                return "\"" + (JSON.parse(data)).msg + "\"";
                            },

                        }
                    },
                    Mobile: {
                        required: true,
                        //phcheck: true,
                        //remote: {
                        //    url: "AccountAPI.aspx",
                        //    type: "POST",
                        //    dataType: "json",
                        //    data: {
                        //        Mobile: function () {
                        //            return $("#combobox").val() + "-" + $("#Mobile").val();
                        //        },
                        //        API: "checkmobile",

                        //    },
                        //    dataFilter: function (data) {
                        //        var x = (JSON.parse(data)).state;
                        //        if (x == "true") {
                        //            return '"true"';
                        //        }
                        //        return "\"" + (JSON.parse(data)).msg + "\"";
                        //    },

                        //}
                    },
                    combobox: {
                        required: true,
                    },
                    EMail: {
                        required: true,
                        email: true,
                        remote: {
                            url: "AccountAPI.aspx",
                            type: "POST",
                            dataType: "json",
                            data: {
                                EMail: function () {
                                    return $("#EMail").val();
                                },
                                API: "checkemail",

                            },
                            dataFilter: function (data) {
                                var x = (JSON.parse(data)).state;
                                if (x.toLowerCase() == "true") {
                                    return '"true"';
                                }
                                return "\"" + (JSON.parse(data)).msg + "\"";
                            },

                        }
                    },
                    EMail2: {
                        required: true,
                        email: true,
                        equalTo: "#EMail",
                    },
                    Password: {
                        pwcheck: true,
                        required: true,
                    },
                    Password2: {
                        required: true,
                        pwcheck: true,
                        equalTo: "#Password",
                    }
                },
                messages: {
                    EMail2: {
                        equalTo: "信箱比對不一致",
                    },
                    Password2: {
                        equalTo: "密碼比對不一致",
                    }
                },
            });

            $.validator.addMethod("pwcheck", function (value) {
                return /^[A-Za-z0-9\d=!\-@._*]*$/.test(value) // consists of only these
                    && /[a-z]/.test(value) // has a lowercase letter
                    && /\d/.test(value) // has a digit
            }, jQuery.validator.format("至少包含英文跟數字"));

            $.validator.addMethod("phcheck", function (value) {
                return /^[09]{2}[0-9]{8}$/.test(value);
            }, jQuery.validator.format("電話格式錯誤"));

        });



  1. debug : 不往後端傳送。
  2. submitHandler: 驗證都成功時submit的情況。
  3. required: 是否必要。
  4. remote: 後端驗證,以ajax方式回傳,要傳入的參數以data傳遞,type=json,回傳參數只能傳true,否則不能正常顯示,解法用datafilter 過濾,正確無誤回傳true,錯誤的話回傳msg。
  5. equalTo: 驗證是否相同
  6. addMethod: 新增驗證格式



2014年6月22日 星期日

BBS

設計軍中公布欄 BBS 系統
提供檔案上傳服務

架設環境
PHP+MySQL

網站demo
http://cpdemo.twbbs.org:8088/bbs

Calenderix

根據開源程式碼 calendarix 版本修改而來
目前專案套用在軍中的行事曆中

架設環境
PHP+MySQL

網站demo
http://cpdemo.twbbs.org:8088/cal/calendar.php

XAMPP 常見問題

Apache錯誤提示
10:33:43 [Apache] Problem detected!
10:33:43 [Apache] Port 80 in use by "Unable to open process" with PID 4!
10:33:43 [Apache] Apache WILL NOT start without the configured ports free!
10:33:43 [Apache] You need to uninstall/disable/reconfigure the blocking application
10:33:43 [Apache] or reconfigure Apache and the Control Panel to listen on a different port
10:33:43 [Apache] Problem detected!
10:33:43 [Apache] Port 443 in use by ""C:\Program Files (x86)\VMware\VMware Workstation\vmware-hostd.exe" -u "C:\ProgramData\VMware\hostd\config.xml"" with PID 5728!
10:33:43 [Apache] Apache WILL NOT start without the configured ports free!
10:33:43 [Apache] You need to uninstall/disable/reconfigure the blocking application
10:33:43 [Apache] or reconfigure Apache and the Control Panel to listen on a different port



80 port和 443 port 被占用,修改系統文件處理:

解決法1:

1.在\ xampp\apache\conf目錄下 ,打开httpd.conf,將80 port 改為未使用port 如 8088
2.在 \ xampp\apache\conf\extra目录下 ,打开httpd-ssl.conf ,將443 port 改為未使用port 如 4433



解決法2:
打開 XAMPP config-> service and port setting 
可設置


解決法3:
修改XAMPP資料夾下兩文件
properties.ini和xampp-control.ini

1.properties.ini


[General]
installdir=D:\xampp
base_stack_name=XAMPP
base_stack_version=1.8.3-1
base_stack_platform=windows
require_root_privileges=1
[Apache]
apache_server_port=80
apache_server_ssl_port=443

apache_root_directory=/xampp/apache
apache_htdocs_directory=D:\xampp/htdocs
apache_domainname=127.0.0.1
apache_configuration_directory=D:\xampp/apache/conf
apache_unique_service_name=
[MySQL]
mysql_port=3306
mysql_host=localhost
mysql_root_directory=D:\xampp\mysql
mysql_binary_directory=D:\xampp\mysql\bin
mysql_data_directory=D:\xampp\mysql\data
mysql_arguments=-u root -P 3306
mysql_unique_service_name=
[PHP]
php_binary_directory=D:\xampp\php
php_configuration_directory=D:\xampp\php


修改為
apache_server_port=8088
apache_server_ssl_port=4431





2. xampp-control.ini,


[ServicePorts]
Apache=80
ApacheSSL=443
MySQL=3306

FileZilla=21
FileZillaAdmin=14147
Mercury1=25
Mercury2=79
Mercury3=105
Mercury4=106
Mercury5=110
Mercury6=143
Mercury7=2224
TomcatHTTP=8080
TomcatAJP=8009
Tomcat=8005


修改成
Apache=8088
ApacheSSL=4431



XAMPP 架設

XAMPP簡介:


什麼是XAMPP?
XAMPP是最流行的PHP開發環境
XAMPP是完全免費且易於安裝的Apache發行版本,其中包含MySQL、PHP和Perl。XAMPP開放源碼套件的設置讓安裝和使用出奇容易。


官網:

https://www.apachefriends.org/zh_tw/index.html

2012年11月30日 星期五

matlab 根據顏色辨識圖像
















要辨識的圖像
可辨識出紅色部分與綠色部分


程式碼部分

matlab 文字辨識


要辨識的圖像








要辨識的文字圖像








程式碼部分
會在圖像一樣的上面打X