jQuery add required to input fields

Solution 1:

$("input").prop('required',true);

DEMO FIDDLE

Solution 2:

You can do it by using attr, the mistake that you made is that you put the true inside quotes. instead of that try this:

$("input").attr("required", true);