<div class="comment">
<form name="myform" onsubmit="return validateform()">
<label for="fname">Full Name</label>
<input type="text" id="fname" name="fullname" placeholder="Your name..">
<label for="email">E-mail</label>
<input type="text" id="email" name="email" placeholder="Your e-mail..">
Rate us<br>
<input type="radio" id="radio1" name="rate">
<label for="radio1">Poor</label>
<input type="radio" id="radio2" name="rate">
<label for="radio2">Good</label>
<input type="radio" id="radio3" name="rate">
<label for="radio3">Excelent</label>
<br>
<label for="subject">Comments</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
<script type="text/javascript">
function validateform(){
var name=document.forms["myform"]["fname"].value;
var poor = document.getElementById("radio1").checked;
var good = document.getElementById("radio2").checked;
var excelent = document.getElementById("radio3").checked;
var text = document.forms["myform"]["subject"].value;
if (name == "" || name==null || !name.match(/^[a-zA-Z]+$/)) {
alert("Please enter name");
return false;
}
if (text == "" || text==null || !text.match(/^[a-zA-Z]+$/)) {
alert("Please enter valid text");
return false;
}
else if (poor==true) {
alert(" Dear " + name + " , We appriciate your feedback. You have rated our site as POOR and your comment was " + text);
return false;
}
else if (good==true) {
alert(" Dear " + name + " , We appriciate your feedback. You have rated our site as GOOD and your comment was " + text);
return false;
}
else if (excelent==true) {
alert(" Dear " + name + " , We appriciate your feedback. You have rated our site as EXCELENT and your comment was " + text);
return false;
}
}
</script>
This is part of the code of a comment section I'm creating.I've done the validation for the name and the text area, but i can't find a way to get an alert message saying, "Dear (name). We appreciate your feedback. You have rated our site as (relevant radio button name) and your comment was (comment on comment area)".Can someone tell me how to display this alert message.
(No need validation for the e-mail)