2012-03-30 301 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 =「所需的信息」

這將解決該問題