http://www.sitepoint.com/html5-forms-javascript-constraint-validation-api/ 1. progressive enhancement: http://jsfiddle.net/trixta/ru7… http://jsfiddle.net/trixta/ru7jt/ http://stackoverflow.com/questions/12470622/how-can-i-check-the-validity-of-an-html5-form-that-does-not-contain-a-submit-but form.checkValidity() https://html.spec.whatwg.org/multipage/forms.html#dom-form-checkvalidity https://html.spec.whatwg.org/multipage/forms.html#statically-validate-the-constraints ===== var form = document.getElementById(“purchaser_form”); form.noValidate = true; form.onsubmit = validateForm; // set handler to validate the form // onsubmit used for easier cross-browser compatibility function validateForm(event) { if (form.checkValidity()) { return true; } else { field = form.querySelector(‘input:invalid, select:invalid, textarea:invalid’); field.focus(); if (field.checkValidity()) { removeInvalid(field); } else { setInvalid(field); }  return false; } } function setInvalid(element) { var message;

繼續閱讀

shopping cart class

refrence http://codereview.stackexchange.com/questions/25671/my-perfect-shopping-cart-class Easy way is copy this code to your php editor. 1、const ID, QTY for column name, it’s can change by yourself. 2、session only check isset. 3、array_push_after() maybe use not good way. 4、$item from CartItemtoArray(), this is array(). not class object. 5、getIndexOfEntry() try to get Array $container at index. So use Array to control, no Object. Becasue I don’t know refrence, answer 1 and 2, How to create item add in cart.

繼續閱讀

When you use PDO, try to get  fetchAll(PDO::FETCH_ASSOC)  fetch(PDO::FETCH_ASSOC) return is Array. This Array have rows, it’s mean : array[0] = array[“field1”, “field2”, “field3”] array[1] = array[“field1”, “field2”, “field3”] …… array[10] = array[“field1”, “field2”, “field3”] So get array index or row maybe not exist, when you try to get value, get error code. You can try to make two function: function ar_get($val, $ar){ return array_key_exists($val, $ar)?$ar[$val]:""; }

繼續閱讀

[轉]PDO学习笔记

http://www.ido321.com/1424.html PDO支持三种异常模式: 默认模式:PDO::ERRMODE_CLIENT 警告模式:PDO::ERRMODE_WARNING 异常模式:PDO::ERRMODE_EXCEPTION(推荐)

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan