![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Dwayne Epps wrote: :: :: function formValidation(thisform) { :: if (checkText(this.first_name, 'Please enter your first name.', 2, :: 15)==false) { :: return true; :: } :: return false; :: } :: :: then within the form tag, I called the function: :: onSubmit="return formValidation(thisform) :: :: I'm not all that proficient with Javascript as I'm still learning. :: Can anyone identify my mistake in the formValidation function? Change the onSubmit line to onSubmit="return formValidation(this.form)" You need to put a period (full stop) between "this" and "form". Also, in your function itself: function formValidation(form) { if (checkText(form.first_name, 'Please enter your first name.', 2, 15)==false) { return true; } return false; } The name of the variable you supply as an argument needs to be what you refer to throughout the function. So, to choose a ludicrous example, you could change it to: function formValidation(cherryBlossom) { if (checkText(cherryBlossom.first_name, 'Please enter your first name.', 2, 15)==false) { -- David Powers ******************************************* No-nonsense reviews of computer books http://japan-interface.co.uk/webdesign/books.html Save 10% on TopStyle CSS Editor ******************************************* |
#3
| |||
| |||
|
|
onSubmit="return formValidation(thisform)" |
|
onSubmit="return formValidation(this.form)" |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Thanks for clarifying that. Event handling is one part of JavaScript that is still only gradually revealing its arcane mysteries to the inner parts of my brain. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Yes, that bit's beginning to sink in - and your explanation is very helpful. It's the way events are handled in DOM Level 2 that freezes my brain. It sounds as though it's very powerful, but since IE doesn't support it, the incentive to study the finer details is somewhat reduced. |
![]() |
| Thread Tools | |
| Display Modes | |
| |