Welcome Guest Search | Active Topics | Sign In | Register

RegularExpressionValidator Functionality for MaskEditValidator Options
Mohana
Posted: Monday, September 29, 2008 8:41:37 AM
Rank: Newbie
Groups: Member

Joined: 9/16/2008
Posts: 3
my requirement is validate the SSN Number format if enter the SSN Number in the MaskEdit
how to achieve this functionality by using MaskEditValidator.


if i use the RegularExpressionValidator for MaskEdit its giving the error

Control 'MaskedEdit2' referenced by the ControlToValidate property of 'RegularExpressionValidator1' cannot be validated.
eo_support
Posted: Monday, September 29, 2008 8:52:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

I don’t think you need to use RegularExpressionValidator on the MaskedEdit control for SSN. You just choose the correct MaskedEdit mask and you should be all set. You can do this by right click the MaskedEdit control, then select "Choose Mask...", then choose "SSN" from that list.

MaskedEditValidator is to check whether the MaskedEdit contains complete data. For example, when the mask is set to SSN, while you won't be able to enter "ABC", you will still be able to enter "123", where as the full SSN is 9 digits. The purpose of MaskedEditValidator is to check against this situation.

Hope this helps.

Thanks
Mohana
Posted: Monday, September 29, 2008 9:55:58 AM
Rank: Newbie
Groups: Member

Joined: 9/16/2008
Posts: 3
my requirement is if i am not enter any thing it should not validate SSN,
if enter anything it should validate.

this is following code i am using, please correct it

<eo:MaskedEdit ID="MaskedEdit2" runat="server" >
<eo:MaskedEditSegment IsRequired="false" Mask="000-00-0000" SegmentType="Mask" />
</eo:MaskedEdit>
<eo:MaskedEditValidator ID="MaskedEditValidator2" runat="server" ControlToValidate="MaskedEdit2" EnableClientScript="true" ErrorMessage="SSN is not valid" Display="None" ></eo:MaskedEditValidator>
eo_support
Posted: Monday, September 29, 2008 11:21:42 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

I don't think you can do "if not enter any thing it should not validate, if enter anything it should validate" with any validators. This "dual logic" does not fit into any built-in validators well. So you will need to use some custom JavaScript. Try to add the following JavaScript code to the end of your page before closing tag of the form element:

Code: JavaScript
//eo_MaskedEdit_IsValid is the function that MaskedEditValidator
//calls to check whether the input is valid. Here you are redefining
//this function so that your customized version, instead of the
//built-in version is called
function eo_MaskedEdit_IsValid(val)
{
    if (typeof("eo_GetObject") == "undefined")
        return true;
	
    var maskedEdit = eo_GetObject(val.controltovalidate);
    if (!maskedEdit)
        return true;
	
    //Check whether user has entered anything. Returns true
    //to indicate the input is valid if user has NOT entered
    //anything	
    var text = maskedEdit.getText();
    if (text == "   -  -    ")
        return true;

    //If user has entered anything, ask the maskedEdit to
    //check whether the input is valid (whether it matches
    //the mask)
    return maskedEdit.isValid();
}

Hope this helps.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.