How to set required field in php and html ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How to set required field in php and html ?

Required

16th Aug 2017, 12:03 PM
Santhoshkumar
Santhoshkumar - avatar
2 Answers
+ 4
In html, simply add the required keyword in the input tag. In php, just check if your post variable (or get but I strongly recommend post) is set and not empty! 😊
16th Aug 2017, 12:20 PM
Drax
Drax - avatar
+ 2
do remember "required" attribute is available only in html5. also allow form to be submitted only when all required fields are filled, then php side validation not require only.
18th Aug 2017, 6:55 AM
Naveen Gunasekaran
Naveen Gunasekaran - avatar