Validation with JS on a Web form

Hello everybody,I have a web form and I need to do input validation for some fields.

either check if the field is empty (this is for fields like name,adresse…).

Or check the validity of the data entered (Name, Age, etc.)

I tried this piece of code for the age field, which I have placed in the JS Header:

function Validate()

{

if((document.forms[0].Child1.value != "")&&(document.forms[0].ChildAge1.value == ""))

{

	alert("Please indicate an age for the child you have listed");

	document.forms[0].ChildAge1.focus();

	return false;

}

else

{

return True;

}

}

Then in the on submit event I put :

return Validate();

It doesnt work.

I’m using the following Notes code under a button when attempting to submit the document, and have my Db Properties generating JS on pages:

@Command([FileSave]);

@Command([FileCloseWindow])

TIA for any assistance

Subject: validation with JS on a Web form

Javascript is case-sensitive, so boolean values should be in lower case, i.e.note the True in your code is in Propercase.

Create a button and put the following code :

if (Validate()) {

document.forms[0].submit();

}

Ashish

Subject: RE: validation with JS on a Web form

Ashish,

Can’t I use the button with the standard @Commands?

@Command([FileSave]);

@Command([FileCloseWindow])

How do I call the function when I am using these commands? Thanks for the tip on the case.

Subject: RE: validation with JS on a Web form

got it working. I had the validation on the subform JS header, and apparently Notes didn’t like that, since the onSubmit was on the main form. I moved it to the main form, and it worked fine.

Subject: In your Validate function: “return True;” should be “return true;”