News1 min ago
HELP Javascript validation
6 Answers
HELP
I have been trying to validate this form for ages (text boxes, checkboxes, radio buttons), everything i have been trying doesn't work! Here is part of the script. Anyone any ideas of what to try?!
function doSubmit()
alert("Your query has been sent.");
return;
}
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
<div class="row">
<div class="label"> Establishment Name</div> <!--end
.label-->
<div class="input">
<input type="text" id="establishment" class="detail"
name="establishment" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Contact Inital</div> <!--end .label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_0" />
Mr</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_1" />
Mrs</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_2" />
Miss</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_3" />
Ms</label>
</div> <!--end .input-->
</div> <!--end .row-->
<div class="row">
<div class="label"> Contact First Name </div> <!--end
.label-->
<div class="input">
<input type="text" id="firstname" class="detail"
name="firstname" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Contact Surname </div> <!--end
.label-->
<div class="input">
<input type="text" id="surname" class="detail"
name="surname" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label">
<p>Contact Telephone Number </p>
</div> <!--end .label-->
<div class="input">
<input type="text" id="telephone" class="detail"
name="telephone" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Preferred Contact Time</div> <!--end
.label-->
I have been trying to validate this form for ages (text boxes, checkboxes, radio buttons), everything i have been trying doesn't work! Here is part of the script. Anyone any ideas of what to try?!
function doSubmit()
alert("Your query has been sent.");
return;
}
</script>
</head>
<body>
<div id="formWrap">
<div id="form">
<div class="row">
<div class="label"> Establishment Name</div> <!--end
.label-->
<div class="input">
<input type="text" id="establishment" class="detail"
name="establishment" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Contact Inital</div> <!--end .label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_0" />
Mr</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_1" />
Mrs</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_2" />
Miss</label>
<br />
<div class="row">
<div class="label">   </div> <!--end
.label-->
<div class"input">
<label>
<input type="radio" name="inital" value="radio"
id="inital_3" />
Ms</label>
</div> <!--end .input-->
</div> <!--end .row-->
<div class="row">
<div class="label"> Contact First Name </div> <!--end
.label-->
<div class="input">
<input type="text" id="firstname" class="detail"
name="firstname" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Contact Surname </div> <!--end
.label-->
<div class="input">
<input type="text" id="surname" class="detail"
name="surname" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label">
<p>Contact Telephone Number </p>
</div> <!--end .label-->
<div class="input">
<input type="text" id="telephone" class="detail"
name="telephone" value="" />
</div> <!--end .input-->
</div> <!-- end .row -->
<div class="row">
<div class="label"> Preferred Contact Time</div> <!--end
.label-->
Answers
Best Answer
No best answer has yet been selected by lawstudent21. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.No, if i wanted someone to write it for me i would of put all the script in!
I have been trying to use the function validateText with var est ect, for text boxes and for radios using function validateRadio () with if(document.contactform.small[0].checked == 0) return false not having any luck though. Was just wondering if anyone knew another way to do it. I have also tried in dreamweaver adding the spry validation but it won't let me select it.
I have been trying to use the function validateText with var est ect, for text boxes and for radios using function validateRadio () with if(document.contactform.small[0].checked == 0) return false not having any luck though. Was just wondering if anyone knew another way to do it. I have also tried in dreamweaver adding the spry validation but it won't let me select it.
-- answer removed --
First things first: validateRadio() isn't a standard JavaScript method - where are you getting that from?
Secondly, your HTML makes no mention of a <form /> object with an id of 'contactform', so document.contactform is NEVER going to work. Use document.getElementById instead:
http://stackoverflow....elected-in-javascript
Secondly, your HTML makes no mention of a <form /> object with an id of 'contactform', so document.contactform is NEVER going to work. Use document.getElementById instead:
http://stackoverflow....elected-in-javascript
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.