0
votes

I am using codeigniter to make a login form using php. A screenshot demonstration

I would like to use the traditional html5 required tag for input fields. The html5 required tag doesnt allow you to submit a page if the input field is empty and it has a good style as it popsup without reloading the page.

I am using codeigniter and even though I've added the required functionality to the input form, it still allows users to submit pages on empty fields, and it gives them the error after the page reloads. and the style is ugly.

How do i make the php codeigniter required tag like the html5 inbuilt required tag

My Php codeigniter code

$this->form_validation->set_rules('username', 'username', 'required');

I would like to make it similar to the html required field style

Username: < input type="text" name="usrname" required >

Thanks in advance

A screenshot demonstration

1
You'll need to do both. The validation rules are only processed on the backend once the form is submitted. - CollinD
Oh right. so does that mean I need to make a form using html inputs and integrate it with the form_validation rules by codeigniter? - mark
you can use jquery validation engine. - Yadhu Babu

1 Answers

0
votes

To make php codeigniter required error message like the html5 inbuilt required tag, you have to deal with some css. Means codeigniter required is server side validation, it it is not succeed, then it will return the error message as a string, on the front end you have to show that in some tag (like div, label, span etc). On that area apply the css so that you can get the error message in any kind of style you want.