Ad

When To Use Form Tags

- 1 answer

I'm working on a page which has an input and a button to add input somewhere to the page using jquery . is it valid to strip form tags and only use input and button tags?

HTML:

<input type="text">
<button type="button" id="add-me">add</button>

JQuery :

$('#add-me').click(function(){
//do stuff
});
Ad

Answer

Yes, you can strip the form tag for showing standard things like that in jQuery. However your question is also tagged php which makes me think you do need it eventually.

Additionally I see a text tag. You can show the text without form as well but it wont submit it anywhere. You can show the input of the textfield with javascript/jQuery.

So for jQuery there is no real reason for form tags. However read this question: Why use a form tag when you're submitting via ajax?

Ad
source: stackoverflow.com
Ad