chwankok
asked on
Separate htm and js
I have this script which included in .htm file. What i want to do is to create another file as .js
And call this script from htm from js.
Basically i want to 2 files than everything work in htm.
It would be more tedious this way.
What do i need to modify and add?
Please let me in detail ya.
Thank you
<script language=JavaScript><!--
function signup_Validator(theForm)
{
if (theForm.contact.value == "")
{
theForm.contact.focus();
alert("Please enter a value for the \"contact.\" field.");
return (false);
}
if (theForm.contact.value.len gth < 20)
{
theForm.contact.focus();
alert("Please enter at least 20 characters in the \"contact.\" field");
return (false);
}
if (theForm.contact.value.len gth > 50)
{
theForm.contact.focus();
alert("Please enter at most 50 characters in the \"contact.\" field");
return (false);
}
return (true);
}
//--></script>
<form method="post" action="member.asp" name="login" onsubmit="return sinup_Validator(this)">
And call this script from htm from js.
Basically i want to 2 files than everything work in htm.
It would be more tedious this way.
What do i need to modify and add?
Please let me in detail ya.
Thank you
<script language=JavaScript><!--
function signup_Validator(theForm)
{
if (theForm.contact.value == "")
{
theForm.contact.focus();
alert("Please enter a value for the \"contact.\" field.");
return (false);
}
if (theForm.contact.value.len
{
theForm.contact.focus();
alert("Please enter at least 20 characters in the \"contact.\" field");
return (false);
}
if (theForm.contact.value.len
{
theForm.contact.focus();
alert("Please enter at most 50 characters in the \"contact.\" field");
return (false);
}
return (true);
}
//--></script>
<form method="post" action="member.asp" name="login" onsubmit="return sinup_Validator(this)">
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you might want to include the language in your script tag:
<SCRIPT language='javascript' src='myjs.js'></script>
<SCRIPT language='javascript' src='myjs.js'></script>
ASKER
Thank you guy.
function signup_Validator(theForm)
{
if (theForm.contact.value == "")
{
theForm.contact.focus();
alert("Please enter a value for the \"contact.\" field.");
return (false);
}
if (theForm.contact.value.len
{
theForm.contact.focus();
alert("Please enter at least 20 characters in the \"contact.\" field");
return (false);
}
if (theForm.contact.value.len
{
theForm.contact.focus();
alert("Please enter at most 50 characters in the \"contact.\" field");
return (false);
}
return (true);
}
then in your .htm file, do this:
<HTML>
<HEAD>
<SCRIPT src='myjs.js'></script>
</head>
<BODY>
<form method="post" action="member.asp" name="login" onsubmit="return sinup_Validator(this)">