Submit form with anchor + javascript is bad practice?

I currently have two anchor tags sending url requests to post votes inside the database, but I want to switch to using forms to keep the URLs clean and avoid duplicate requests (this is actually not a problem, but makes it look ugly).

Now the bindings should contain a span tag inside to add additional background elements to the buttons (links) via css, so I can not use the usual form buttons.

Do you consider filing these forms with anchors using javascipt as bad practice? I can think of some other solutions, but all of them do not seem to be worth the trouble. Should I leave a no-script backup where users with javascript disabled get the ability to send URL requests (do I really want to avoid URL requests at all)? If, then how will it be best accomplished?

Thanks,
Simon.

+3
source share
3 answers

you can use <button>in your form. it can contain content, and you can style it as you wish.

, <a>, , POST. , <a>, POST!

+8

:

<button type="submit" value="upvote">
  <span>Vote Up</span>
</button>

<button type="submit" value="downvote">
  <span>Vote Down</span>
</button>

JavaScript , , , , .

+5

.
CSS , .

, , . , , No- Script Firefox.

+1
source

Source: https://habr.com/ru/post/1755147/


All Articles