Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

restrict text in a text box

Status
Not open for further replies.

DrAsh

Technical User
May 3, 2001
46
US
I got two questiosn actually:

1) I have a text box on my form. I do not want anyone to be able to write in it as it's a special text box. Text values taken from another part of the page will be inserted into that text box. I don't want the users to be able to manual fill in the box. Anyone know how?

2) I want to merge to button functions into one. I have a grading button and a submit button. I want to set my exam up in such a way that when the person is done the exam, they press submit. Submit will invole the grading function. If the results of hte grading function is a pass, then and only then will the submit form work. If they fail, an alert should come up stating you failed and must retake the exam.

My code, if your not already familiar with it.
<html>

<head><a name=&quot;top&quot;>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<title>admin TEST</title>
<script>

function printWindow(){
bV = parseInt(navigator.appVersion)
if (bV >= 4) window.print()
}

function check() {
if (document.forms[0].test_taker.value == &quot;&quot;) {
alert(&quot;Cannot submit, you have not entered in your name. Please enter your name and then press submit.&quot;)
return false
}
else {
return true
}
}
</script>
<script>
function check () {
if (document.forms[0].test_taker.value == &quot;&quot;) {
alert(&quot;Cannot Submit. You have not entered your name. Please enter your name and then press submit.&quot;)
return false
}
else {
return true }
}

</script>
</head>

<body bgcolor=&quot;#97BCE6&quot;>
<script language=&quot;JAVASCRIPT&quot;>
function grading(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){
var right = 0;

if (a1 == true){
right = (right + 1);
}
if (a2 == true){
right = (right + 1);
}
if (a3 == true){
right = (right + 1);
}
if (a4 == true){
right = (right + 1);
}
if (a5 == true){
right = (right + 1);
}
if (a6 == true){
right = (right + 1);
}
if (a7 == true){
right = (right + 1);
}
if (a8 == true){
right = (right + 1);
}
if (a9 == true){
right = (right + 1);
}
if (a10 == true){
right = (right + 1);
}

if (right >= 9){
alert(&quot;You Passed. Now you must press Submit to Sumit your Results to HHCR and then scroll below to print your certificate&quot;);
name_on_certificate.value = document.forms[0].test_taker.value;
}
if (right < 9){
alert(&quot;You Failed and You must retake this test. Hit 'OK' and 'Refresh'. Don't forget to re-enter your name&quot;);
}
}
</script>


<table border=&quot;0&quot; width=&quot;100%&quot;>
<tr>
<td width=&quot;20%&quot;> <img src=&quot;hhcrlogonoinc1.gif&quot; width=&quot;135&quot; height=&quot;64&quot;
alt=&quot;Home HealthCare Resources&quot;></td>
<td width=&quot;61%&quot;><p align=&quot;center&quot;><strong><big><big><big>CORPORATE COMPLIANCE PROGRAM TEST
FOR ADMINISTRATIVE PERSONNEL</big></big></big></strong></td>
<td width=&quot;24%&quot;><img src=&quot;mcclogo.gif&quot; width=&quot;114&quot; height=&quot;63&quot;
alt=&quot;Maternal Child Consortium&quot; align=&quot;left&quot;></td>
</tr>
</table>

<table border=&quot;0&quot; width=&quot;269&quot; height=&quot;770&quot;>
<tr>
<td width=&quot;600&quot; height=&quot;96&quot;></a><p align=&quot;left&quot;><br>
<em>Directions:<br>
<br>
Answer True (T) or False (F) to the following statements. Use either the mouse or
space-bar to mark your answer. Afterwards, you must grade the exam. If you Passed,
submit your exam for validation and print your certificate for your records.<br>
<br>
</em></td>
</tr>
<tr>
<td width=&quot;1530&quot; height=&quot;641&quot;><form method=&quot;POST&quot; name=&quot;Administration Test Results&quot;
target=&quot;_blank&quot; action=&quot;--WEBBOT-SELF--&quot; onSubmit=&quot;return check();&quot;>
<!--webbot bot=&quot;SaveResults&quot; startspan S-Email-Format=&quot;TEXT/PRE&quot;
S-Email-Address=&quot;training@hhcr.com&quot; B-Email-Label-Fields=&quot;TRUE&quot;
B-Email-Subject-From-Field=&quot;FALSE&quot; S-Email-Subject=&quot;Administration TEST RESULTS&quot;
S-Builtin-Fields=&quot;Date Time REMOTE_USER&quot; U-Confirmation-Url=&quot;results were submitted.htm&quot; --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;0&quot;><!--webbot
bot=&quot;SaveResults&quot; endspan --><input type=&quot;hidden&quot; name=&quot;Test Taken&quot; value=&quot;Administration&quot;><div
align=&quot;right&quot;><table border=&quot;0&quot; width=&quot;311&quot; height=&quot;500&quot; bgcolor=&quot;#97BCE6&quot;>
<tr>
<td width=&quot;614&quot; height=&quot;32&quot; colspan=&quot;3&quot;><font face=&quot;Arial&quot;><em><strong>ENTER YOUR NAME
HERE:</strong> </em><input type=&quot;text&quot; name=&quot;test_taker&quot; size=&quot;36&quot;></font><br>
</td>
</tr>
<tr>
<td width=&quot;46&quot; height=&quot;32&quot;><div align=&quot;center&quot;><center><p><u><strong><font face=&quot;Arial&quot;>TRUE</font></strong></u></td>
<td width=&quot;46&quot; height=&quot;32&quot; align=&quot;center&quot;><div align=&quot;center&quot;><center><p><u><font
face=&quot;Arial&quot;><strong>FALSE</strong></font></u></td>
<td width=&quot;200&quot; height=&quot;32&quot; align=&quot;center&quot;></td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;32&quot;><div align=&quot;center&quot;><center><p><input type=&quot;radio&quot; name=&quot;Q1&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;32&quot; align=&quot;center&quot;><div align=&quot;center&quot;><center><p><input
type=&quot;radio&quot; name=&quot;Q1&quot; value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;32&quot; align=&quot;center&quot; nowrap><div align=&quot;left&quot;><p>1. Violations
or suspected violation of federal and state regulations must be reported
immediately. <br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;78&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q2&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;78&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q2&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;78&quot; nowrap><div align=&quot;left&quot;><p>2. Inspector General
Act of 1978, Healthcare Fraud Prevention of 1995, Health Insurance Portability &
Accountability Act of 1996 and Balanced Budget Act of 1997 are legislation passed by
Congress to address fraud and abuse.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;46&quot; align=&quot;center&quot; nowrap> <input type=&quot;radio&quot; name=&quot;Q3&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;44&quot; height=&quot;46&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q3&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;46&quot; nowrap><div align=&quot;left&quot;><p>3. Fraud is an
unintentional deception or misrepresentation by a provider.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;71&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q4&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;71&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q4&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;71&quot; nowrap><div align=&quot;left&quot;><p>4. Abuses are
practices or services of providers that are inconsistent with sound medical practice
(Billing, Documentation errors).<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;65&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q5&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;65&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q5&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;65&quot; nowrap><div align=&quot;left&quot;><p>5. Fraud/Abuse
prevention and compliance with all federal and state regulations is the responsibility of
the Compliance Officer only.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;27&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q6&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;27&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q6&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;27&quot; nowrap><div align=&quot;left&quot;><p>6. An effective
compliance program will detect and prevent fraud and abuse.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q7&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q7&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;40&quot; nowrap><div align=&quot;left&quot;><p>7. HHCR/MCC Compliance
Officer is Tom Galvin.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q8&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q8&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;40&quot; nowrap><div align=&quot;left&quot;><p>8. Corporate Counsel
and Compliance Officer are responsible for approving Corporate Standards at HHCR/MCC.<br>
</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q9&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;40&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q9&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;40&quot; align=&quot;left&quot; nowrap><div align=&quot;left&quot;><p>9. The
Administrator is responsible for reviewing data prior to cost reporting calculation.</td>
</tr>
<tr align=&quot;center&quot;>
<td width=&quot;46&quot; height=&quot;21&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q10&quot;
value=&quot;CORRECT&quot;></td>
<td width=&quot;46&quot; height=&quot;21&quot; align=&quot;center&quot; nowrap><input type=&quot;radio&quot; name=&quot;Q10&quot;
value=&quot;INCORRECT&quot;></td>
<td width=&quot;550&quot; height=&quot;21&quot; align=&quot;left&quot; nowrap>10. Medical records must be retained
for a period of no less than six (6) years.</td>
</tr>
</table>
<script>
onsubmit=&quot;return check ()&quot;
</script>
</div><div align=&quot;center&quot;><center><p><input type=&quot;button&quot;
value=&quot;Click this Button to Grade Your Exam&quot; name=&quot;grader2&quot;
onclick=&quot;grading(Q1[0].checked, Q2[0].checked, Q3[1].checked, Q4[0].checked, Q5[1].checked, Q6[0].checked, Q7[0].checked, Q8[1].checked, Q9[0].checked, Q10[0].checked)&quot;>
</p>
</center></div><div align=&quot;center&quot;><div align=&quot;center&quot;><center><p><input type=&quot;reset&quot;
value=&quot;Refresh&quot; name=&quot;reset_button&quot;> <input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;></p>
</center></div><div align=&quot;center&quot;></div></div><div align=&quot;center&quot;><center><p><a
href=&quot;javascript:printWindow()&quot;>Click to Print for your records.</a> </p>
</center></div>
</form>
</td>
</tr>
</table>

<p align=&quot;center&quot;><font face=&quot;Arial Black&quot; color=&quot;#FF0000&quot;>YOUR CERTIFICATE (KEEP FOR YOUR
RECORDS)</font></p>
<div align=&quot;center&quot;><center>

<table border=&quot;1&quot; width=&quot;61%&quot; height=&quot;387&quot;>
<tr>
<td width=&quot;100%&quot; background=&quot;CERTIFICATE_FRAME.jpg&quot; height=&quot;381&quot; valign=&quot;middle&quot;><p
align=&quot;center&quot;><br>
<font face=&quot;Arial Black&quot; size=&quot;4&quot;>Congratulations</font><br>
<br>
<input type=&quot;text&quot; name=&quot;name_on_certificate&quot; size=&quot;20&quot;></p>
<p align=&quot;center&quot;><font face=&quot;Arial Black&quot; size=&quot;3&quot; color=&quot;#000000&quot;>You have completed the
HHCR/MCC<br>
Compliance Training Program</font></p>
<p align=&quot;center&quot;><script Language=&quot;JavaScript&quot;>
function tickClock()
{
// this tells the browser to call the &quot;tickClock()&quot; function every 1 second
setTimeout(&quot;tickClock()&quot;, 1000);

thisTime = new Date()
hours = thisTime.getHours()
minutes = thisTime.getMinutes()
seconds = thisTime.getSeconds()

// convert the digit to string
// make sure there're at least 2 digits
if (hours>=12)
{
hours-=12
}

hourString=&quot;0&quot;+hours+&quot;&quot;
minuteString=&quot;0&quot;+minutes+&quot;&quot;
secondString=&quot;0&quot;+seconds+&quot;&quot;

// format the hour
hour1=parseInt(hourString.charAt(hourString.length-1))
hour2=parseInt(hourString.charAt(hourString.length-2))

// format the minute
minute1=parseInt(minuteString.charAt(minuteString.length-1))
minute2=parseInt(minuteString.charAt(minuteString.length-2))

// format the seconds
second1=parseInt(secondString.charAt(secondString.length-1))
second2=parseInt(secondString.charAt(secondString.length-2))


}
</script> <!-- --><!-- --> <script LANGUAGE=&quot;JavaScript&quot;>
<!--
var date=new Date();
document.write(&quot;<font size=-2 face='Arial, Helvetica, sans-serif' color=003399> &quot;+ date);
//-->
</script>
</td>
</tr>
</table>
</center></div>

<p align=&quot;center&quot;><br>
</p>
</body>
</html>


 
To make your text box readonly, add this to the tag:
<text onFocus=&quot;this.blur();&quot;>

and here's a once and for all function for you -- hodge-podge of the two, which you will call onSubmit for the form:

function grading(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){
var right = 0;

if (a1 == true){
right = (right + 1);
}
if (a2 == true){
right = (right + 1);
}
if (a3 == true){
right = (right + 1);
}
if (a4 == true){
right = (right + 1);
}
if (a5 == true){
right = (right + 1);
}
if (a6 == true){
right = (right + 1);
}
if (a7 == true){
right = (right + 1);
}
if (a8 == true){
right = (right + 1);
}
if (a9 == true){
right = (right + 1);
}
if (a10 == true){
right = (right + 1);
}

if (right >= 9){
alert(&quot;You Passed.&quot;);
name_on_certificate.value = document.forms[0].test_taker.value;
}
if (right < 9){
alert(&quot;You Failed and You must retake this test. Hit 'OK' and 'Refresh'. Don't forget to re-enter your name&quot;);
return false;
}

if (document.forms[0].test_taker.value == &quot;&quot;) {
alert(&quot;Cannot Submit. You have not entered your name. Please enter your name and then press submit.&quot;);
return false;
}

return true;
}


just do like before, but change your onSubmit to:'

<form onSubmit=&quot;return grading(Q1[0].checked, Q2[0].checked, Q3[1].checked, Q4[0].checked, Q5[1].checked, Q6[0].checked, Q7[0].checked, Q8[1].checked, Q9[0].checked, Q10[0].checked)&quot;>

And change it so that you only have one submit button -- and that will be what fires your new function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top