Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-22-2005, 03:58 PM   PM User | #1
fmontoya
New to the CF scene

 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
fmontoya is an unknown quantity at this point
required field script

I am trying to get a required form script for a form located
http://int.lansce.lanl.gov/UserMtg6/reg_form.html
Can someone look at the source and tell me what I am doing wrong. The script is located at the bottom before the end of the body. Greatly appreciiated.
fmontoya is offline   Reply With Quote
Old 03-22-2005, 05:17 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
where is the script at? i dont see it in your source code, but you can use some javascript to return an alert if a field is left blank and if left blank don't submit
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
  Copyright 2004.  The Regents of the University of California.
  See http://www.lanl.gov/misc/copyright.html

  $Header: /src/CVS/weblogin/login.shtml,v 1.10 2004/03/15 23:26:58 jrc Exp $
-->

<HTML>
<HEAD>
  <TITLE>
    Weblogin: Login
  </TITLE>
  <META NAME="keywords" CONTENT="web login, web initial sign on,
    authentication, CRYPTOCard">
  <META NAME="description" CONTENT="Web Login Form">
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<script type="text/javascript"><!--
function validateform(){
if(document.weblogin.form_zn.value==""){
alert('Please enter a Z Number');
return false;
}
else if(document.weblogin.form_password.value==""){
alert('Please enter a password');
return false;
}
else {
return true;
}
}
//-->
</script>
</HEAD>

<!--
  Put ONLOAD in the BODY to get the cursor focus right
-->
<BODY ONLOAD="document.forms.weblogin.form_zn.focus()">

<P>
<!--
  Display ERRORMSG
-->
  <STRONG><FONT COLOR=RED></FONT></STRONG>
</P>
<p>
  <table width="480" align="center" border=0 cellpadding=0 cellspacing=0 marginheight="0" marginwidth="0" bgcolor="#E3E3DC">
  <tr>
    <td valign="top" bgcolor="#000000">
      <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#000000">

  <tr align="right">
    <td nowrap><a href="http://www.lanl.gov/"><img src="images/bar_black1.gif" width="151" height="16" align="left" border="0" hspace="8" alt="Los Alamos National Laboratory" title="Los Alamos National Laboratory"><img src="images/bar_black2.gif" width="65" height="16" border="0" alt="Lab's home page" title="Lab's home page"></a><a href="http://phonebook.lanl.gov/"><img src="images/bar_black3.gif" width="45" height="16" border="0" alt="Search for people in the Lab's directory" title="Search for people in the Lab's directory"></a><a href="http://www.lanl.gov/search"><img src="images/bar_black4.gif" width="45" height="16" border="0" alt="Search the Laboratory's Web site" title="Search the Laboratory's Web site"></a></td>
  </tr>
</table>
    </td>
  </tr>
  <tr>
    <td valign="top"><img src="images/authtop2.gif" title="Authentication" alt="Authentication" width="480" height="50" border="0"></td>
  </tr>

  <tr>
    <td valign="top"><br>
<FORM NAME="weblogin" METHOD="post" onsubmit="return validateform()" ACTION="login.php">
    <table border="0" valign="top" cellpadding=0 cellspacing=0>
        <tr>
          <td valign="top" width="30"><img src="images/transparent.gif" width="30" height="1" alt=" "></td>
          <td valign="top" width="190">          
            <table border="0" valign="top" cellpadding=0 cellspacing=0 width="190">
			<tr>
                <td align="right" nowrap><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">Z Number:&nbsp;</font></td>

                <td valign="top">
                  <input TYPE="text" MAXLENGTH="6" SIZE="6" NAME="form_zn" VALUE="">
                </td>

              </tr>
              <tr>
                <td align="right" nowrap><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">Passcode:&nbsp;</font></td>
                <td valign="top">
                  <input type="password" maxlength="8" size="8" name="form_password" value="" AUTOCOMPLETE="off">

                </td>
              </tr>
              <tr>
                <td align="center" valign="top" height="27">&nbsp;</td>
                <td valign="top" border="0" nowrap>
<input type="submit" value="Sign In">                
<!--<input src="images/signin.gif" VALUE="submit" TYPE="image" name="submit" alt="Sign In" title="Sign In" height="25" width="60" border="0">--><br>
<INPUT TYPE="hidden" VALUE="https://int.lansce.lanl.gov/UserMtg6/reg_form.html" NAME="referer">
                </td>
              </tr>

            </table>          
          </td>
          <td width="20"><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
          <td valign="top" >
            <p><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">
              This LANL network authentication allows access to most LANL Web applications.<br>
              <br>
              <a href="help.shtml">Need Help/Problems?</a><br>

              </font></p>
            </td>
          <td valign="top" width="20"><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
        </tr>
      </table></form>
  </td>
  </tr>
  <tr>
    <td valign=top>

    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E3E3DC">
        <tr>
          <td width="20"><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
          <td valign="top"><br><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000" size="-2">
          <strong>NOTICE:</strong><br>
           Information from this server resides on a computer system
           funded by the U.S. Department of Energy. Anyone using this system consents to
           monitoring of this use by system or security personnel. For complete conditions
           of use see <a href="http://www.lanl.gov/misc/disclaimer.html">Disclaimer/Privacy</a>.</td>
          <td><br><div align="center"><a href="http://www.lanl.gov/"><img src="images/lanl_color_logo2.gif" alt="LANL logo" title="LANL logo" width="133" height="49" hspace="6" vspace="0" border="0"></a></div></font></td>

          <td valign="top" width="20" ><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
        </tr>
		<tr><td><br></td></tr>
		<tr>
  <td><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
  <td valign="bottom" colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000" size="-2">Operated
	 by the <a href="http://www.universityofcalifornia.edu/">University of California</a> for the <a href="http://www.nnsa.doe.gov/">National
	 Nuclear Security Administration</a> of the US <a href="http://www.energy.gov/">Department of Energy.</a> &nbsp;

	 <a href="http://www.lanl.gov/misc/copyright.html">Copyright
	 &copy; 2004 UC</a> | <a href="http://www.lanl.gov/misc/disclaimer.html">Disclaimer/Privacy</a><br><br></font></td>
  <td><img src="images/transparent.gif" width="20" height="1" alt=" "></td>
 </tr>
      </table>
  </td>
  </tr>

  </table>
</p>

</BODY>
</HTML>
but if javascript is disabled then they will be able to submit the form you may be able to put something in the php login script that you have to tell the user that some fields weren't entered but were required
_Aerospace_Eng_ is offline   Reply With Quote
Old 03-22-2005, 06:39 PM   PM User | #3
fmontoya
New to the CF scene

 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
fmontoya is an unknown quantity at this point
this is the script

The new URL is: http://www.lansce.lanl.gov/reg_form.html
Everything on the form has to be required.
This is the script:

<script language="text/javascript">

<!--

function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("Full Name", "Organization", "Address", "City", "Zip Code", Telephone", Fax", "E-Mail");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Full Name", "Organization", "Address", "City", "Zip Code", Telephone", Fax", "E-Mail");
// dialog message
var alertMsg = "Please complete the following fields:\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
}
if (obj.type == undefined){
var blnchecked = false;
for (var j = 0; j < obj.length; j++){
if (obj[j].checked){
blnchecked = true;
}
}
if (!blnchecked){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}

if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
// -->
</script>
</body>

Last edited by fmontoya; 03-22-2005 at 07:55 PM..
fmontoya is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:27 PM.


Advertisement
Log in to turn off these ads.