![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 2
Rep Power: 0
![]() |
Need help with required form script
I am trying to use a required form script for this web page:
http://www.lansce.lanl.gov/reg_form.html I cant seem to get it to work. I'm not sure if I need to put it somewhere different in my source code. It is located at the bottom prior to the end of the body. Can someone please look at source and give advice. Thanks. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
this is what i use:
function checkrequired(which)
{
var pass=true;
if (document.images)
{
for (i=0;i<which.length;i++)
{
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required")
{
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0))
{
pass=false;
break;
}
}
}
}
if (!pass)
{
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
{
return true;
}
}then in the form tag put: <form method="blahblah" action="blahblah" name="myform" onsubmit="return checkrequired(this);"> then when your coding the form element that you want to be required do this: <input type="text" name="requiredMyTextElement"> what that does is any form element that has the word required in the name it will check to see if there is a value inserted in the element. I found this script on some site a while back.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2005
Posts: 2
Rep Power: 0
![]() |
Thank you for your help. I'm going to attempt to get it to work.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|