/*!
* Copyright (c) 2009 Francesco Mele jsbeans@francescomele.com
*
* This Software is licenced under the LGPL Licence (GNU Lesser General
* Public License).
* In addition to the LGPL Licence the Software is subject to the
* following conditions:
*
* i every modification must be public and comunicated to the Author
* ii every "jsbean" added to this library must be self consistent
* except for the dependence from jsbeans-x.x.x.js
* iii copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Validator extensions for comparing two input's values
* @for Validator
* @namespace jsbeans
* @static
* */
jsbeans.Validator.sameAs = {
/**
* Default messages for Validator.sameAs extension
* @property sameAs.messages
* @type JSON
* @static
* */
messages: {
en: "does not match",
it: "non coincide"
},
/**
* Checks if {@param} <code class="param">input</code> has same value of {@param} <code class="param">compare</code>
* @method assertSameAs
* @param input {DOM} first input
* @param compare {String} the id of a second input whose value will be compared to first one
* @return {boolean} true if <code class="param">input</code>'s value is equals to <code class="param">compare</code>'s using <code>==</code> operator.
* @static
* */
assertSameAs: function(input, compare) {
var compare = document.getElementById(compare);
if (typeof compare == "undefined" || !compare.value) {
return false;
}
return input.value == compare.value;
}
};