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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script doesn't work in Netscape

Status
Not open for further replies.

RycherX

Programmer
Mar 18, 2002
20
0
0
US
What do I have to do here to make it both IE and Netscape compatible?





function Blank_TextField_Validator()
{
// Check the value of the element named EMPNUM
// from the form named Main
if (Main.EMPNUM.value == "")
{
// If null display and alert box
alert("Please enter Employee Number.");
// Place the cursor on the field for revision
Main.EMPNUM.focus();
// return false to stop further processing
return (false);
}
//CHECKS TO MAKE SURE VALUES ARE NUMBERS ONLY
var input = Main.EMPNUM.value

if (isNaN(input)) {
alert("Entries must be numbers only.");
Main.EMPNUM.focus();
return false;

}

// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < Main.main_menu.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (Main.main_menu[counter].checked)
radio_choice = true;
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert(&quot;Please make button selection.&quot;)
return (false);
}
return (true);
 
you had two problems:
1) missing closing brackets for the function.
2) you have to add document., to specify it's an element under current document.
so this should work (worked for me with mozilla):
Code:
function Blank_TextField_Validator()
{
        // Check the value of the element named EMPNUM
        // from the form named Main
		var theForm;
		theForm = document.Main;
        if (document.Main.EMPNUM.value == &quot;&quot;)
        {
                // If null display and alert box
                alert(&quot;Please enter Employee Number.&quot;);
                // Place the cursor on the field for revision
                document.Main.EMPNUM.focus();
                // return false to stop further processing
                return (false);
        }
               //CHECKS TO MAKE SURE VALUES ARE NUMBERS ONLY
        var input = document.Main.EMPNUM.value

        if (isNaN(input)) {
                alert(&quot;Entries must be numbers only.&quot;);
                document.Main.EMPNUM.focus();
                return false;

       }

        // set var radio_choice to false
        var radio_choice = false;

        // Loop from zero to the one minus the number of radio button selections
        for (counter = 0; counter < document.Main.main_menu.length; counter++)
        {
                // If a radio button has been selected it will return true
                // (If not it will return false)
                if (document.Main.main_menu[counter].checked)
                        radio_choice = true;
        }

        if (!radio_choice)
        {
                // If there were no selections made display an alert box
                alert(&quot;Please make button selection.&quot;)
                return (false);
        }
        return (true);      
	}
(-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top