Skip to main content
March 4, 2009
Question

Flash form broken by required+mask

  • March 4, 2009
  • 4 replies
  • 1922 views
The code below creates a flash form with a required field and a mask that defines the phone format. This code renders immediately with an error and red border, with a mouseover that says "error in phone text".
If i remove either the "required" or the "mask" parts, the problem goes away, but they don't play well together.

Is this a bug?

<cfform format="flash">
<cfinput type="text" name="phone" label="Phone" required="yes" mask="999-999-9999">
</cfform>
    This topic has been closed for replies.

    4 replies

    BKBK
    Community Expert
    Community Expert
    March 20, 2009
    In the meantime, you could make the form use your own message. In fact, I suspect that's what the Coldfusion Team might tell you.

    You can use the message attribute to replace the default error message "Error in phone text". You could also use tooltip to hint the user. Or even both, like this

    <cfinput type="text" name="phone" label="Phone" required="yes" mask="999-999-9999" message="Enter phone number" tooltip="Format: 012-345-6789">





    BKBK
    Community Expert
    Community Expert
    March 20, 2009
    Sorry, A_mclean. I can assure you I'm aware of masks here and elsewhere in Coldfusion. Just a loss of attention there. I was thinking the digits, but the 9s rolled out. There's no need to read too much into it.

    I'll maintain what I said. When the form initially opens, the field is empty, whereas it is supposed to have a string of digits, hence the error message. I am presuming that that is why we get the error message.

    You wrote:
    actually it disappears when you type in ANY number at all. Even just 1.

    No, it doesn't disappear until the third digit. Having said that, this might well turn out to be a bug. Suppose you type in 999. The error message disappears. The field changes from red to green.

    If Coldfusion indeed reasons as I have presumed, then the error message should reappear when you use the backspace button to delete the 9s. However, it remains green. To me, this inconsistency amounts to a bug.

    March 20, 2009
    Sorry I didn't mean to snap. I've searched high and low for an answer to this and am getting frustrated.

    What I can't understand is that the mask only gives the field a context for formatting. The required tag should only be making sure you type something eventually. Neither of them on their own will show an error off the bat.

    You're right about typing in 999, my mistake - I was typing it in my test server where the mask was 9-999-999-9999 to include the international country code.

    I've submitted this as a bug to Adobe, hopefully they can fix.
    BKBK
    Community Expert
    Community Expert
    March 20, 2009
    I presume that that is the expected behaviour. After all, the field is required and must contain the digits. However, when you open the form, it is empty. The form's validation therefore tells you there is an error in the input. The error message disappears when you enter 999.


    Edit: Duly corrected. 'the digits' in place of 'the 9s'.
    March 20, 2009
    No... this is not the expected response since the 9s are only a placeholder mask for numeric digits. For example if I were to require a canadian postal code, I would use mask="A9A9A9" (9 for numeric digits, A for aplhabet).

    Conversely if i wanted to specify the format of a US postal code, it would look something like mask="99999", which would accept "90210".

    And as for the red validation border disappearing when you type in 999, actually it disappears when you type in ANY number at all. Even just 1.

    Please respond only if you understand ColdFusion.
    Participant
    March 17, 2009
    I'd like to know the answer to this as well... Anyone?