Robzy
04-09-2003, 05:15 PM
Before I go bald from pulling my hair out, I hoped maybe someone here may be able to give me a hand. I am to validate a form for this assignment, particularly ensuring the state field is filled, as is the zip code (with numbers, no letters), and at least one checkbox and radio button is checked. Here is the coding from the external JS file. Any help would be greatly appreciated!
function checkItAll()
{
checkState(document.frmCustInfo.ddlState);
checkZip(document.frmCustInfo.txtZip);
editCheckbox(document.frmCustInfo.chkPrice);
editCheckbox(document.frmCustInfo.chkReputation);
editCheckbox(document.frmCustInfo.chkValue);
editCheckbox(document.frmCustInfo.chkRecommendation);
editCheckbox(document.frmCustInfo.chkOtherFactor);
checkEmAll()
theRadioButtons(document.frmCustInfo.rdoUse);
}
// End of checkItAll
// Begin State Verifier
function checkState(field)
{
uSState = field.selectedIndex
if ( uSState == 0)
{
{alert("Please enter an appropriate state.");
}
return false;
}
// End checkState
// Begin Zip Verifier
function checkZip(field){
var allowedOnes = "0123456789"
if (field.value.length == 5)
{
{alert("Please enter a 5 digit zip code.");
return false;
}
for (i=0; i < field.value.length; i++)
{
zipSearch = field.value.substr(i,1)
if (allowedOnes.indexOf(zipSearch) == -1)
{
alert("Please ensure that your zip code is comprised of 5 digits and no other characters.");
return false;
}
}
}
}
// End validateZip
// Begin Checkbox Verifier
var lotsOfCheckboxes = 0
function editCheckbox(){
editCheckbox(document.frmCustInfo.chkPrice)
editCheckbox(document.frmCustInfo.chkReputation)
editCheckbox(document.frmCustInfo.chkValue)
editCheckbox(document.frmCustInfo.chkRecommendation)
editCheckbox(document.frmCustInfo.chkOtherFactor)
if (field.checked) {
lotsOfCheckboxes++
}
else
{
lotsOfCheckboxes--
}
}
function checkEmAll(){
if (lotsOfCheckboxes == 0)
{
alert("Please choose at least one reason you chose to purchase our product.");
return false;
}
}
}
// End the Confusing Checkboxes Verifier
// Beginning the Radiobox Verifier
function theRadioButtons(field){
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
return;
}
else;{
}
alert("Please choose how you will use the product you purchased.");
}
}
// End Radiobox Verifier
function checkItAll()
{
checkState(document.frmCustInfo.ddlState);
checkZip(document.frmCustInfo.txtZip);
editCheckbox(document.frmCustInfo.chkPrice);
editCheckbox(document.frmCustInfo.chkReputation);
editCheckbox(document.frmCustInfo.chkValue);
editCheckbox(document.frmCustInfo.chkRecommendation);
editCheckbox(document.frmCustInfo.chkOtherFactor);
checkEmAll()
theRadioButtons(document.frmCustInfo.rdoUse);
}
// End of checkItAll
// Begin State Verifier
function checkState(field)
{
uSState = field.selectedIndex
if ( uSState == 0)
{
{alert("Please enter an appropriate state.");
}
return false;
}
// End checkState
// Begin Zip Verifier
function checkZip(field){
var allowedOnes = "0123456789"
if (field.value.length == 5)
{
{alert("Please enter a 5 digit zip code.");
return false;
}
for (i=0; i < field.value.length; i++)
{
zipSearch = field.value.substr(i,1)
if (allowedOnes.indexOf(zipSearch) == -1)
{
alert("Please ensure that your zip code is comprised of 5 digits and no other characters.");
return false;
}
}
}
}
// End validateZip
// Begin Checkbox Verifier
var lotsOfCheckboxes = 0
function editCheckbox(){
editCheckbox(document.frmCustInfo.chkPrice)
editCheckbox(document.frmCustInfo.chkReputation)
editCheckbox(document.frmCustInfo.chkValue)
editCheckbox(document.frmCustInfo.chkRecommendation)
editCheckbox(document.frmCustInfo.chkOtherFactor)
if (field.checked) {
lotsOfCheckboxes++
}
else
{
lotsOfCheckboxes--
}
}
function checkEmAll(){
if (lotsOfCheckboxes == 0)
{
alert("Please choose at least one reason you chose to purchase our product.");
return false;
}
}
}
// End the Confusing Checkboxes Verifier
// Beginning the Radiobox Verifier
function theRadioButtons(field){
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
return;
}
else;{
}
alert("Please choose how you will use the product you purchased.");
}
}
// End Radiobox Verifier