|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
OnChange Versus OnSubmit
Morning,
I have a very large form that uses an external js page for validation. That works fine. But I also have these fields that have functions attached. The one I wrote to check the value of another field works fine if you use form onSubmit. However if you try to attach it to a field with the OnChange function it breaks. <!-- Begin function function Form_Validator(testform) { if ((testform.InternetAccess.value != "") && (testform.VPEmail.value == "")) { alert("Please enter your VP's email address."); return false; } return (true); } <!--Field <select name="InternetAccess" size="1" onChange="Form_Validator(this)"> <option selected> </option> <option value="Internet Access">Internet Access</option> <option value="Internet Access Enhanced">Internet Access Enhanced</option> <option value="Intellitrader">Intellitrader</option> </select> Any thoughts would be appreciated. Thanks Laura |
|
#2
|
|||
|
|||
|
RE: OnChange Versus OnSubmit
I assume that when you are using it for onSubmit, you are calling the function from the <form> tag. When you use "this" as an argument for the function, "this" sends a reference to the element that the function is being called from. Since your validation expects that argument to be a reference to the form, when you use it in your select box, it is sending a reference to the select box, not the form. all you need to do is change the argument so it references the form...like so.
<select name="InternetAccess" size="1" onChange="Form_Validator(this.form)"> this will send a reference to the form instead of a reference to the select box which should solve your problem. |
|
#3
|
|||
|
|||
|
RE: OnChange Versus OnSubmit
Wow. Thanks for that I was just about to post that I had figured it out. I did that by finding another example not necessarily becasue I knew what I was doing. Thanks for explaining.
Laura |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > OnChange Versus OnSubmit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|