Closed Thread Icon

Preserved Topic: Messing with mr.maX's scripts Pages that link to <a href="https://ozoneasylum.com/backlink?for=18497" title="Pages that link to Preserved Topic: Messing with mr.maX&amp;#039;s scripts" rel="nofollow" >Preserved Topic: Messing with mr.maX&#039;s scripts\

 
Author Thread
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-21-2001 00:28

I've been trying to modify one of the validation scripts mr.maX is kind enough to supply at his site. I think my logic works, but I must be missing something because it still won't work. I have a form with yes and no radio buttons named alert. The form also has a text area with the name new_content. I want the script to send an alert if new_content is blank, but only if the value of the alert radio buttons is set to yes. If the value of alert is set to no, I want the form to be able to be submitted with new_content being blank. Here's what I have tried:

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- ;

// Written by mr.maX, http://www.max.co.yu/

function testBlank(field1, field2, msg) {
if ((field1.value == "") && (field2.value == "yes")){
alert(msg);
field.focus();
field.select();
return false;
} else
return true;
}

function testAndSubmit(form) {
return (
testBlank(form.new_content, form.alert, "You have not entered any content to display in the alert box. If you don't want an alert box, select the no option.")
);
}
// -->
</SCRIPT>

Thanks for your helps!!

-Butcher-

Lao is good
Bipolar (III) Inmate

From: Freakshow, CA
Insane since: May 2001

posted posted 12-21-2001 03:04

I dont know jack about java script so this is just a shot in the dark. But could radio buttons be using true/false?

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-21-2001 03:24

I don't know much about JavaScript either, but I do know that I set the value of the radio buttons in their input tags, so it's yes and no (I think).

Thanks

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 12-21-2001 18:26

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- ;

// Written by mr.maX, http://www.maxworld.co.yu/

function getRadioValue(radioButtons) {
&nbsp;&nbsp;&nbsp;&nbsp;for (var i = 0; i < radioButtons.length; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (radioButtons[i].checked) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return radioButtons[i].value;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;return "";
}

function testBlank(field1, field2, msg) {
&nbsp;&nbsp;&nbsp;&nbsp;if ((field1.value == "") && (getRadioValue(field2) == "yes")) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(msg);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field1.focus();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field1.select();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;
&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;
&nbsp;&nbsp;&nbsp;&nbsp;}
}

function testAndSubmit(form) {
&nbsp;&nbsp;&nbsp;&nbsp;return (
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;testBlank(form.new_content, form.alert, "You have not entered any content to display in the alert box. If you don't want an alert box, select the no option.")
&nbsp;&nbsp;&nbsp;&nbsp;
}

// -->
</SCRIPT>


butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 12-22-2001 00:43

Thanks Max!!

« BackwardsOnwards »

Show Forum Drop Down Menu