Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Star Rating Feedback using Javascript
Rajamanickam
Rajamanickam

Posted on • Edited on

Star Rating Feedback using Javascript

In this tutorial has helped you learn how to create star rating feedback using javascript

First of all, create simple form

<form method="GET" name="feedback" action="#" onsubmit="feedBack(); return false">      <input type="radio" name="star" value="">      <textarea cols="30" placeholder="Describe your comment"></textarea></form>
Enter fullscreen modeExit fullscreen mode

while development use thefontawesome icons andgoogle fonts

Now get the input values usingjavascript

function feedBack() { var rating_Count = document.querySelector("input[name=star]:checked").value;    var comment = document.getElementById('comment').value; document.getElementById('comment_text').innerHTML = comment;    document.getElementById('star_count').innerHTML = rating_Count;  }
Enter fullscreen modeExit fullscreen mode

Adding simple validation


document.getElementById('comment').value === ''

if value is empty shown error message.

Youtube Video :https://youtube.com/shorts/2LLre0ld1pk?feature=share
Demo :https://star-rating-feedback.vercel.app/
Portfolio :https://rajamanickam.vercel.app/
Github :https://github.com/erajamanickam/star-rating-feedback
Codepen :https://codepen.io/erajamanickam/pen/dyjydOj

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I’m a web developer. I spend my whole day, practically every day
  • Location
    Chennai, India
  • Education
    M.Sc IT
  • Work
    Software Developer @ Xerago
  • Joined

More fromRajamanickam

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp