i have a form to fill, i want to check if all the textboxes are empty if they are then show asterisks beside the empty ones, if not (they are full of info) alert the page saved. the checking part and showing asterisks is working the saving part isnt working for me.
function txtchk(tbox, asterisk, f, name) { //the f parameter is an empty paragraph
var bol = Boolean;
if (bol === true) {
if (document.getElementById(tbox).value == "") {
document.getElementById(asterisk).style.display = "block";
document.getElementById(f).innerHTML = name + " required";
document.getElementById(f).style.display = "block";
return bol = true;
}
else {
document.getElementById(asterisk).style.display = "none";
document.getElementById(f).style.display = "none";
return bol = false;
}
}
else {
alert ("saved");
}
}
function combiner() {
txtchk("tbox1", "asterisk1", "f1", "Product Name");
txtchk("tbox2", "asterisk2", "f2", "Description");
txtchk("tbox3", "asterisk3", "f3", "Image");
txtchk("tbox4", "asterisk4", "f4", "Unit Price");
txtchk("tbox5", "asterisk5", "f5", "ISBN");
txtchk("tbox6", "asterisk6", "f6", "Author");
txtchk("tbox7", "asterisk7", "f7", "Ammount in the stock");
txtchk("tbox8", "asterisk8", "f8", "Color");
txtchk("ops", "asterisk9", "f9", "Size");
txtchk("tbox10", "asterisk10", "f10", "Manufacturer");
txtchk("tbox11", "asterisk11", "f11", "Ammount in the stock");
}
this function in called by a button (on click)
Aucun commentaire:
Enregistrer un commentaire