MaskValidator.java :  » Ajax » smartgwt-2.1 » com » smartgwt » client » widgets » form » validator » Java Open Source

Java Open Source » Ajax » smartgwt 2.1 
smartgwt 2.1 » com » smartgwt » client » widgets » form » validator » MaskValidator.java
package com.smartgwt.client.widgets.form.validator;

/**
 * Validate against a regular expression mask, specified as validator.mask. If validation is successful a transformation
 * can also be specified via the validator.transformTo property. This should be set to a string in the standard format
 * for string replacement via the native JavaScript replace()  method.
 */
public class MaskValidator extends Validator {

    public MaskValidator() {
        setAttribute("type", "mask");
    }

    /**
     * Set the mask.  Eg : ^\s*(1?)\s*\(?\s*(\d{3})\s*\)?\s*-?\s*(\d{3})\s*-?\s*(\d{4})\s*$
     *
     * @param mask the mask
     */
    public void setMask(String mask) {
        setAttribute("mask", mask);
    }

    /**
     * Return the mask.
     *
     * @return the mask
     */
    public String getMask() {
        return getAttribute("mask");
    }

    /**
     * Set the transformTo. Eg : $1($2) $3 - $4
     *
     * @param transformTo the transformTo
     */
    public void setTransformTo(String transformTo) {
        setAttribute("transformTo", transformTo);
    }

    /**
     * Return the transformTo.
     *
     * @return the transformTo
     */
    public String getTransformTo() {
        return getAttribute("transformTo");
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.