Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 views
in Technique[技术] by (71.8m points)

cakephp - Different validation messages in different web browsers

I am a newbie in CakePHP and doing my first application - first blog from cakephp tutorial. Everything is fine, but one thing bothers me. When I define validation rules in my model, validations are working.

But every web browser show different message. For example firefox show message in czech language (i'm from czech), chrome show "Please fill out this field" and internet explorer show "This field cannot be left blank".So i tried to translate the messages (by add parameter message into model validation). this is working, but only in internet explorer, other browsers are without change. Is there any way, how to have same validation messages same in all browsers?

Validation in model:

public $validate = array(
        'title' => array(
            'rule' => 'notEmpty',
            'message' => 'Please fill.....'
        ),
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you are talking about client side validation messages. If I'm right the messages you see are created by your browser and are browser dipendant. Cake just tells the browser that the field is required by setting the required property in the input tag.

Instead the actual validation that cake does is made server side. If your browser sends data to the server then cake validates the data and returns error messages


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...