Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Validation > required validator
Added by tm_jee, last edited by Philip Luppens on Feb 10, 2007  (view change) show comment


RequiredFieldValidator checks if the specified field is not null.


  • fieldName - field name if plain-validator syntax is used, not needed if field-validator syntax is used



        <!-- Plain Validator Syntax -->
        <validator type="required">
            <param name="fieldName">username</param>
            <message>username must not be null</message>

        <!-- Field Validator Syntax -->
        <field name="username">
            <field-validator type="required">
            	   <message>username must not be null</message>