Sha256: 00ff8f827fd64051091d8a5958c78f3d6c2609b95e3579929a68480a2df4a622
Contents?: true
Size: 1.3 KB
Versions: 11
Compression:
Stored size: 1.3 KB
Contents
// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors. // Portions ©2008-2010 Apple Inc. All rights reserved. // License: Licensed under MIT license (see license.js) // ========================================================================== sc_require('validators/validator') ; /** Requires a valid email format. @class @extends SC.Validator @version 1.0 */ SC.Validator.Email = SC.Validator.extend( /** @scope SC.Validator.Email.prototype */ { validate: function(form, field) { return (field.get('fieldValue') || '').match(/.+@.+\...+/) ; }, validateError: function(form, field) { var label = field.get('errorLabel') || 'Field' ; return SC.$error("Invalid.Email(%@)".loc(label), label) ; } }) ; /** This variant allows an empty field as well as an email address. @class @extends SC.Validator.Email @author Charles Jolley @version 1.0 */ SC.Validator.EmailOrEmpty = SC.Validator.Email.extend( /** @scope SC.Validator.EmailOrEmpty.prototype */ { validate: function(form, field) { var value = field.get('fieldValue') ; return (value && value.length > 0) ? value.match(/.+@.+\...+/) : true ; } }) ;
Version data entries
11 entries across 11 versions & 1 rubygems