1
$this->form_validation->set_message('is_date', 'You must enter a valid date.');
$this->form_validation->set_rules('loadingdate', 'Loading Date', 'required|is_date|xss_clean');
$this->form_validation->set_rules('departuredate', 'Departure Date', 'required|is_date|xss_clean');
$this->form_validation->set_rules('arrivaldate', 'Arrival Date', 'required|is_date|xss_clean');
$this->form_validation->set_rules('cutoffdate', 'Cut Off Date', 'required|is_date|xss_clean');
$this->form_validation->set_rules('loadingdate', 'Loading Date', 'required|is_date|xss_clean');

I have created a custom form validation function called 'is_date' , which i have set a custom error message for.

'You must enter a valid date.'

How can I customise the error message so that it displays the field name, since I have multiple fields which will use this validation? eg.

'Loading Date must be a valid date.' 'Cut Off Date must be a valid date.'

1 Answer 1

2

Add %s into the string where you want the field name to be:

"The %s field must contain a valid URL."

(I assume you are defining the message in form_validation_lang.php)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.