The Required attribute works great inside the form Tags:
<form>
<input type="text" name="user" required>
</form>
But can I use the required attribute if I cannot wrap it as a form? Outside of the form this input required does not work for me:
<input type="text" name="user" required>
I can replicate it with JavaScript but Id like to know if outside form is possible
The "required" attribute only works on form submit and since your input has no form the browser does not know what to validate on submit.
What the w3c says about "required": When present, it specifies that an input field must be filled out before submitting the form.
This would only be possible with JS like:
document.getElementById('your_input_id').validity.valid
Already discussed here 4 years ago: