damiancds Posted April 5, 2010 Share Posted April 5, 2010 So I'm going through and validating my site, and i get an error/ warning about a form tag without an action attribute.The truth is, I'm using these empty form tags for fieldsets, and I wasn't sure if i needed a form tag containing the fieldsets so I added oneMy question is, do i need the opening and closing form tags to use fieldsets, and if i do, how can I have a form tag with an action that does nothing (should it just be action=" ")much appreciated,thanks, Link to comment Share on other sites More sharing options...
boen_robot Posted April 5, 2010 Share Posted April 5, 2010 Why do you need a fieldset if you don't have a form? If it's just for appearance's sake, you might be able to somehow duplicate it by the use of a relatively positioned element within another (relatively or absolutely) positioned element.If you have some form fields either way, then yes, you need a form. And if you have a form, it must have an action. Specifying action="" will mean the action is on the very same page the form is on. Link to comment Share on other sites More sharing options...
jeffman Posted April 5, 2010 Share Posted April 5, 2010 If you are using the form controls for AJAX, or if you're not posting the form at all, then you can safely remove the form tags altogether.I do occasionally use a fieldset to group elements semantically, and to simplify the process of generating element collections in JavaScript. But if the border and legend are not required, a div is usually easier.If it is convenient to group elements in a form because that creates the form.elements[] array, then you can always use an empty string for the form action. As boen points out, that means that the form will submit to itself, but if the form is never submitted, then there should not be a problem. Link to comment Share on other sites More sharing options...
damiancds Posted April 6, 2010 Author Share Posted April 6, 2010 I went with divs and after redoing the fieldsets, it actually turned out better, the look at least, the code is a tad more messy but I like it better now,thanks, Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.