View Full Version : Required fields and printing

04-13-2005, 06:37 AM
Hello, I have a form that I have a number of required fields either text boxes or check boxes that are required to be filled in before they can print it out and give it to someone else in the company. I have put a print button on the page so I was hopeing you could tell me two things:

1. How do I make a feild required
2. How to I make the print button check the required fields have all been filled before bringing up the print box?

<input type="button" value="Print" onClick="window.print();" tabindex="50">

Thanks in advance.

04-13-2005, 07:14 AM
<script type="text/javascript">function validate(oFrm){
if (oFrm.theTextField.value == ""){ //textbox
return false;
if (!oFrm.theCheckboxField.checked){ //checkbox
return false;
//...do the same with other required fields

return true; //all inputs are valid here
<input type="button" value="Print" onclick="if (validate(this.form)) window.print();" tabindex="50" />
But no validation will be performed if the user uses the browser's menu (File->Print) to print the page.