HTML form cleartext

alicean

New Member
Joined
Feb 8, 2005
Messages
1
OK.. I have an html form with 2 issues #1. The reset button doesn't work. #2 when you complete the form and click submit it should place the contents on the clipboard (for pasting) later then clear the fields(that works fine except for the clearing the fields part). Please help!!!! (see below)...

Code:
<html>

<head>
<script language=javascript>

function autotab(max, field) {
	if (!/^\d+$/.test(field.value)) { //digits only
		field.value = '';
		return false;
	}
	if (field.value.length<max) 
		return true; //still room
		
	var el, e = 0, f = field.form;
	while (el = f.elements[e++]) 
		if (el == field) break; //find field position
			f.elements[e].focus(); //move focus
	return false;
}

function copytext() {

	if (document.forms[0].RequestedCreditAmount.value=='') {
		alert('Please enter Requested Credit Amount.');
		document.forms[0].RequestedCreditAmount.focus();
		return false;
	}
	if (document.forms[0].AppliedCreditAmount.value=='') {
		alert('Please enter Applied Credit Amount.');
		document.forms[0].AppliedCreditAmount.focus();
		return false;
	}
	if (document.forms[0].AccountNumber.value=='') {
		alert('Please enter Account Number.');
		document.forms[0].AccountNumber.focus();
		return false;
	}
	if (document.forms[0].MTN1.value==''){
		alert('Please enter the area code of the MTN.');
		document.forms[0].MTN1.focus();
		return false;
	}
	if (document.forms[0].MTN2.value==''){
		alert('Please enter the area code of the MTN.');
		document.forms[0].MTN2.focus();
		return false;
	}
	if (document.forms[0].MTN3.value==''){
		alert('Please enter the range of the MTN.');
		document.forms[0].MTN3.focus();
		return false;
	}
	if (document.forms[0].ReasonCode.value=='') {
		alert('Please enter Reason Code.');
		document.forms[0].ReasonCode.focus();
		return false;
	}
	if (document.forms[0].Date.value=='') {
		alert('Please enter Date.');
		document.forms[0].Date.focus();
		return false;
	}
	if (document.forms[0].Details.value=='') {
		alert('Please enter Details.');
		document.forms[0].Details.focus();
		return false;
	}

	document.forms[0].txtcopy.value = ("Your credit request has been approved and applied. We have remarked the account and attached a summary of what was done. Please allow up to two billing cycles for the credit to reflect on the account.\n\n" + 
		"\t\t\t\tRequested credit amount:  " + document.forms[0].RequestedCreditAmount.value + "\n" +
		"\t\t\t\tApplied credit amount:  " + document.forms[0].AppliedCreditAmount.value + "\n\n" +
		"Account #: " + document.forms[0].AccountNumber.value + "\n" +
		"MTN:  " + document.forms[0].MTN1.value + "-" + document.forms[0].MTN2.value + "-" + document.forms[0].MTN3.value + "\n" +
		"Reason Code: " + document.forms[0].ReasonCode.value + "\n" +
		"Date: " + document.forms[0].Date.value + "\n\n" +
		"Details: \n" + document.forms[0].Details.value + "\n\n\n" +
		"Do not reply to this email. Replies will not be answered. If you have any questions regarding your credit request, Please contact your supervisor");
   
  t=document.forms[0].txtcopy.createTextRange();
  t.select();
  t.execCommand('copy');
  
  //document.forms[0].reset();
  return true;
  
}
</script>

<body>
<table width=95% border=0 cellspacing=0 cellpadding=0>
<form name="frmARC">
<tr>
	<td colspan=2 align=center><font size=5>Approved Credit Response</font></td>
</tr>
<tr>
	<td colspan=2 align=center><hr></td>
</tr>
<tr>
	<td width=40% valign=top align=right>Requested credit amount:</td>
	<td align=left><input name="RequestedCreditAmount" size=8 maxlength=8></td>
</tr>
<tr>
	<td width=40% valign=top align=right>Applied credit amount:</td>
	<td align=left><input name="AppliedCreditAmount" size=8 maxlength=8></td>
</tr>
<tr>
	<td width=40% valign=top align=right>Account Number:</td>
	<td align=left><input name="AccountNumber" size=15 maxlength=15></td>
</tr>
<tr>
	<td width=40% align=right>MTN:</td>
	<td><input type=text name="MTN1" maxlength=3 size=3 onkeyup="return autotab(3, this)"><input type=text name="MTN2" maxlength=3 size=3 onkeyup="return autotab(3, this)"><input type=text name="MTN3" maxlength=4 size=4 onkeyup="return autotab(4, this)"></td>
</tr>
<tr>
	<td width=40% align=right>Reason Code:</td>
	<td><input type=text name="ReasonCode" maxlength=4 size=4></td>
</tr>
<tr>
	<td width=40% align=right>Date:</td>
	<td><input type=text name="Date" size=12 maxlenght=12></td>
</tr>
<tr>
	<td width=40% valign=top align=right>Details:</td>
	<td><textarea name="Details" rows=3 cols=45 wrap></textarea></td>
</tr>
<tr>
	<td colspan=2 align="center">
		<input type="button" value="Submit" onclick="copytext();">
		<input type=button value="Reset" onclick="cleartext();">
		<input type=hidden name="txtcopy">
	</td>
</tr>
</form>
</table>

</body>
</html>

Edited by Von Pookie
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Reset Button?

I assume you have written a script for the reset button, Cleartext() ??? If the button doesnt work it might be that theres something wrong with the script.

Try using just this it worked on my form:

"input type="reset"value="Reset Form"

Hope it helps!!!
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top