overwrite Mage_Sales_Model_Quote_Address
<?xml version="1.0"?> <config> <modules> <Empire_Sales> <version>1.0.0.0.0</version> </Empire_Sales> </modules> <global> <models> <sales> <rewrite> <quote_address>Empire_Sales_Model_Quote_Address</quote_address> </rewrite> </sales> </models> </global> </config>
File: /app/code/local/Empire/Sales/Model/Quote/Address.php
<?php class Empire_Sales_Model_Quote_Address extends Mage_Sales_Model_Quote_Address { /** * Validate address attribute values * * @return bool */ public function validate() { $errors = array(); $helper = Mage::helper('customer'); $this->implodeStreetAddress(); if (!Zend_Validate::is($this->getFirstname(), 'NotEmpty')) { $errors[] = $helper->__('Please enter the first name.'); } if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) { $errors[] = $helper->__('Please enter the street.'); } if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) { $errors[] = $helper->__('Please enter the city.'); } if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { //$errors[] = $helper->__('Please enter the telephone number.'); } $_havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip(); if (!in_array($this->getCountryId(), $_havingOptionalZip) && !Zend_Validate::is($this->getPostcode(), 'NotEmpty')) { $errors[] = $helper->__('Please enter the zip/postal code.'); } if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) { $errors[] = $helper->__('Please enter the country.'); } if ($this->getCountryModel()->getRegionCollection()->getSize() && !Zend_Validate::is($this->getRegionId(), 'NotEmpty')) { $errors[] = $helper->__('Please enter the state/province.'); } if (empty($errors) || $this->getShouldIgnoreValidation()) { return true; } return $errors; } }
相关推荐
### jQuery.Validate核心知识点详解 #### 一、简介与基本用法 `jQuery.validate`插件是一种基于jQuery的表单验证工具,它可以帮助开发者快速实现客户端数据校验功能,提高用户体验的同时减少服务器端的压力。该...
nameGroup: "firstName lastName" // 将firstName和lastName作为一组验证 } }); ``` 五、动态验证 在某些场景下,我们可能需要根据用户的行为或表单的其他字段动态调整验证规则。jQuery.validate支持动态添加、...
lastname: "required", username: { required: true, minlength: 2 }, // ... } ``` 3. **自定义错误消息**:使用`messages`对象来覆盖默认的错误信息,提供更友好的提示。未定义的message将使用默认信息。...
INSERT INTO Employee(FirstName, LastName, SupervisorID) VALUES('Cheung','Carin',201); INSERT INTO Employee(FirstName, LastName, SupervisorID) VALUES('Cheung','Geoffrey C',201); INSERT INTO Employee...
error.insertAfter("#lastname"); else error.insertAfter(element); } }); ``` `highlight`和`unhighlight`分别用于高亮显示和取消高亮显示验证失败的元素: ```javascript $(“.selector”).validate({ ...
在这个例子中,`for...in`循环会依次输出`firstName`、`lastName`和`age`这三个属性及其对应的值。注意,它并不会区分对象自身和从原型链继承的属性。 然而,有时候我们可能只想获取对象自身的属性,而不包括从原型...
`jQuery Validate` 插件是实现这一功能的有力工具,它提供了一套便捷、可扩展的验证机制。下面将详细介绍`jQuery Validate`插件的使用方法、常见规则以及如何自定义验证规则。 首先,要使用`jQuery Validate`插件,...
<input id="lastname" name="lastname" class="required" /> ``` 对于电子邮件字段,我们可以使用 `email` 类来验证输入是否符合电子邮件格式: ```html ``` 密码和确认密码字段的验证则需要自定义规则,因为...
将名称精确地划分为两个字段{ firstName, lastName } 修复了大写字母,小写字母,iNVERSE大写字母和其他错误样式的情况 处理情侣(“ John and Jane Doe”) 如果存在多个姓氏,则正常降级以将整个字符串放在...
indiv.LASTNAME = lastname; indiv.DOB = dob; indiv.STATE = state; indiv.SaveChanges(); } Collapse Copy Codevoid InsertNewIndividual( int id, string firstname, string middlename, string ...
LastName string `json:"last_name,omitempty" validator:"require"` }{} person.FirstName = "Apisit" validateErr := validator.Validate(person) if validateErr != nil { log.Printf("validation error: %v", ...
例如,`SELECT * FROM Persons WHERE LastName IN ('Adams','Gates')`选取LastName为Adams或Gates的记录。 13. **BETWEEN...AND运算符**:`BETWEEN`用于选取在两个值之间的记录。例如,`SELECT * FROM Persons ...
`jQuery.validate.js` 是一个功能强大的表单验证插件,它充分利用了 jQuery 的优势来快速实现表单验证。该插件支持多种内置验证规则,同时也允许用户自定义验证规则,从而能够适应各种复杂的表单验证需求。 #### 二...
For example, if the clustered index is on (lastname, firstname) and a nonclustered index is on firstname, the firstname value will not be duplicated in the nonclustered index leaf rows. Note The ...
SELECT LASTNAME, SALARY, BONUS, COMM FROM EMPLOYEE WHERE SALARY > 22000 AND BONUS IN (400, 500) AND COMM < 1900 ORDER BY LASTNAME ``` 使用IN关键字可以简化多个OR条件。 9. 查找活动号为10、80或180,...
- **示例**: `SELECT * FROM Persons WHERE LastName IN ('Adams', 'Carter');` —— 从Persons表中选择LastName为Adams或Carter的记录。 **3.4 BETWEEN操作符** - **语法**: `SELECT * FROM table_name WHERE ...
(lastname IN VARCHAR2, firstname OUT VARCHAR2) AS BEGIN SELECT Firstname INTO firstname FROM Authors WHERE Lastname = lastname; END; ``` 转换过程中,需要注意以下几点: 1. **参数声明**:SQLServer...
self.lastName = lastName self.age = age def getFullName(self): return self.firstName + " " + self.lastName # 其他getter和setter方法... ``` 接着,我们可以创建一个`Family`类来存储家庭成员,包括...