2012-03-30 304 views
1

这似乎是一个正确的代码,但是当我尝试跳过第一个名称字段时,我没有收到错误消息。相反,我看到一个带有感叹号的小黄色三角形,出现在名字字段旁边。这可能是什么原因?谢谢。requiredFieldError does not work

<fx:Declarations> 
    <s:RadioButtonGroup id="phoneRadioButtonGroup"/> 
    <mx:StringValidator id="firstNameValidator" source="{firstNameTextInput}" 
    property="text" requiredFieldError="This field is required" required="true"/> 
    <mx:StringValidator id="lastNameValidator" source="{lastNameTextInput}" 
    property="text" required="false" tooShortError="Please enter at least four characters" minLength="4"/> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 
<s:Form width="380" height="615" backgroundColor="#56A1B9"> 
    <s:FormHeading label="Contact Editor"/> 

    <s:FormItem width="252" height="36" label="First Name" required="true"> 
    <s:TextInput id="firstNameTextInput"/> 
    </s:FormItem> 

    <s:FormItem width="251" height="36" label="Last Name" required="false"> 
    <s:TextInput id="lastNameTextInput"/> 
    </s:FormItem> 

    <mx:HRule width="100%" height="15"/> 

    <s:FormItem width="252" height="37" label="Email" required="true"> 
    <s:TextInput id="emailTextInput"/> 
    </s:FormItem> 
+0

据我所知,在这个框架内,这一点感叹在三角形中标记“未填写必填字段”的错误消息。这是许多表单的默认设置。不过,我不确定如何改变这一点。 – CodeMouse92 2012-03-30 21:03:19

+0

感谢您的帮助。我发现为什么发生这种情况由于某种原因,如果我将表单设置为spark组件,它不起作用。与mx它工作正常 – Max 2012-03-30 23:13:24

+0

请确保你回答自己的问题,并接受你的答案。 – CodeMouse92 2012-03-31 00:48:21

回答

0

设置所需的字段.. 和设置的errorMessage =“所需的信息”

这将解决该问题