Javascript validation, Alert me!

Hi, I have a Form that needs to be validated before it is saved.

The HTML button is:

The validation is:

function validRequired()

{

alert(“1”);

var thisdoc = document.forms[0]

if(thisdoc.internetaddress.value == “”)

{

alert(“You may not leave Email blank.”);

thisdoc.internetaddress.focus();

return false;

}

else if(thisdoc.answer.value == “”)

{

alert(“You may not leave Answer blank.”);

thisdoc.answer.focus();

return false;

}

else

{

return _doClick(‘852572A40043994D.e3110ef4f3b1b667852572a3004df42d/$Body/0.11F6’, this, null)

}

}

I see the “1” alert but nothing else works!!! I tried to figure out what is wrong and compare with other related post on this forum, but I could not find a solution ! Can you help ?

And one more thing, is there a way to avoid the “return _doClick…” that doClick reffers to a Notes Button that contains:

@Do(@Command([FileSave]); @Command([ToolsRunMacro];“(ThisAgent)”))

Thanks for your help !

Subject: Javascript validation, Alert me !

It may be as simple as a missing semi colon aftervar thisdoc = document.forms[0]

If there are errors when you run javascript code the icon in the bottom left hand corner of explorer will change. Double clicking on it will display the error message which may give you an indication of where the error occurs.

Subject: Javascript validation, Alert me !

Hi,

As far as replacing the “_doClick”…

Use “thisdoc.submit()” in your function in place of the “_doClick”, then put the agent name “(ThisAgent)” in your “WebQuerySave” event.

HTH

Subject: Javascript validation, Alert me !

Thanks to both of you !

I am so glad it works now. I could not bypass the doClick since I want to remain in the document because the Agent Prints response to the browser. Here is the final code:

function validate()

{

var Msg;

Msg=“”;

if (document.forms[0].InternetAddress.value==“”) {

Msg=Msg+"You must type the Email address.\n"; }

if (document.forms[0].Answer.value==“”) {

Msg=Msg+"You must type the Answer.\n"; }

questionoption = -1;

for (i=0;i<document.forms[0].Question.length;i++) {

if (document.forms[0].Question[i].checked) {

user_input = document.forms[0].Question.value;

questionoption = i; } }

if ( questionoption == -1 ) {

Msg=Msg+“You must select a Question.\n”; }

if (document.forms[0].P1.value==“”) {

Msg=Msg+"You must type the New Password.\n"; }

if (document.forms[0].P1.value.length<4) {

Msg=Msg+"The New Password must be at least 4 characters.\n"; }

if (document.forms[0].P1.value!=document.forms[0].P2.value) {

Msg=Msg+"The passwords do not match, please retype.\n"; }

if (Msg !=“”) { alert(“Please revise the following information(s):\n\n”+Msg);return false }

else

{

// if the SaveButton has been modified, the ID will change

return _doClick('852572A40043994D.e3110ef4f3b1b667852572a3004df42d/$Body/0.121E', this, null);

}

}