In the form, this calls only function_1:
Expand|Select|Wrap|Line Numbers
- <input type="submit" value="thevalue" name="goodname" onclick="return function_1(this.form);function_2(this.form);" />
Expand|Select|Wrap|Line Numbers
- function function_1(health)
- {
- if(health.phone.value=="")
- {
- alert("Please enter your home telephone number.\n");
- return false;
- }
- return true;
- function_2();
- }
- function function_2(health)
- {
- if(health.first_name.value.length<2)
- {
- alert("Please enter your first name.\n");
- return false;
- }
- return true;
- }
So I tried this in the form, but it produces the error "health has no properties":
Expand|Select|Wrap|Line Numbers
- <input type="submit" value="thevalue" name="goodname" onclick="return callThem(this.form);" />
Expand|Select|Wrap|Line Numbers
- function callThem()
- {
- function_1();
- function_2();
- }
- function function_1(health)
- {
- if(health.phone.value=="")
- {
- alert("Please enter your home telephone number.\n");
- return false;
- }
- return true;
- }
- function function_2(health)
- {
- if(health.first_name.value.length<2)
- {
- alert("Please enter your first name.\n");
- return false;
- }
- return true;
- }