javascript - Proper way to create an HTML5 input element that is "required" -


what proper way create html5 input element "required" attribute?

for example, in html, use like:

<input id="myid" name="myname" type="text" required> 

but need in javascript using:

var inputelement = document.createelement("input");     inputelement.id = "myid";     inputelement.name = "myname";     inputelement.type = "text"; 

once create element, how add "required" attribute?

you can set others, can use true or string.

inputelement.required = true; 

or

inputelement.required = "required"; 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -