custom CSS on error messages

28 views
Skip to first unread message

Jacob Phillips

unread,
Jul 14, 2015, 3:58:31 PM7/14/15
to backbon...@googlegroups.com
I just want to make the error message text red (but not the text input)

I see that when I call validate() a tag like this is added for a "Required" error message: 

<div data-error>Required</div>


I thought I read in another post that you can set the "errorClassName" to an error class...using the fieldClass option. 

schema: {
            firm
: { type: 'Select', options: ['', 'Mr', 'Mrs', 'Ms'] },
            name
: {
                type
: 'Text', validators: ['required'], fieldClass:'errorName'
           
},


Then just have some CSS: 

        .errorName {
            color
: red;
       
}


I can get *everything* in that field to turn red, but I just want the error message text to turn red. 

How to do this? 

Or if this is not supported, how can I write a simple class on the tag <div data-error>, e.g. 

#someParentId data-error {
color:red;
}

Dmitry Chusovitin

unread,
Jul 15, 2015, 4:14:36 PM7/15/15
to backbon...@googlegroups.com
Use Form.Field.errorClassName

schema: {
    name: {
        type: 'Text', validators: ['required'], errorClassName: 'fieldWithError'
    }
}

#someParentId .fieldWithError [data-error] {
    color: red;
}



вторник, 14 июля 2015 г., 22:58:31 UTC+3 пользователь Jacob Phillips написал:
Reply all
Reply to author
Forward
0 new messages