Avatar of gallipro
gallipro asked on

How do I enable a print page button after successful form validation?

I am creating a form for a customer that is meant to be printed and not submitted. The requirement is after all the required fields are filled in and validated but a print button, the form should automatically prompt to print the window. Here is a link

The print button should be disabled until the form validation returns true, or there should be one button and after successful validation, the page should print.

Avatar of undefined
Last Comment
Dany Balian

8/22/2022 - Mon

Assuming your validation is in place all you have to do is call "window.print();" where the validation returns true and a print dialog will come up.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Dany Balian

try something like this??
<script language="JavaScript">	
	function validatethenprint()
		if (document.getElementById("field1").value.length<1) {
			alert('Please specify Field 1.');
		 	return false;}
		if (document.getElementById("field2").value.length<1) {
			alert('Please specify Field 2.');
		 	return false;}
		if (document.getElementById("field3").value.length<1) {
			alert('Please specify Field 3.');
		 	return false;}
<form name="myform" action="#" method="post" onsubmit="validatethenprint();return false;">
<input type="Text" name="field1" id="field1"><br />
<input type="Text" name="field2" id="field2"><br />
<input type="Text" name="field3" id="field3"><br />
<input type="Submit" value="Validate and Print">

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck