![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Here you go, and thanks!! function formvalidation(thisform) { * * if (emptyvalidation(thisform.CustName.value,"Customer Name is empty")==false) {thisform.CustName.focus(); return false;}; * * if (emailvalidation(thisform.CustEmail.value,"Illegal E- mail")==false) {thisform.CustEmail.focus(); return false;}; * * if (thisform.CellPhone.value==null || thisform.CellPhone.value=="" || thisform.CellPhone.value==" ") { * * * *thisform.CellPhone.value="000-000-0000"; * * } else { * * * *if (phonevalidation(thisform.CellPhone.value,"Please enter a valid cell phone")==false) { * * * * * thisform.CellPhone.focus(); return false; * * * *}; * * }; * * thisform.submit(); } Change "thisform.submit()" to "return true" However, Reading you original post again, you wrote: *> <a class="save_menu" * href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; *> * * document.Detail_Screen.submit();">Update</>a [snip] *> At the end of the javascript validation routine, we have this: * *> thisform.submit(); * *> So, the form seems to submit, but not the way we want it to. *We want *> it to execute the validation routine first. So, I think you're saying "Why isn't validation performed when the user clicks on Update?" So, I believe this is an accurate description of what's happening. I've looked for something to back it up, but all I can find are unreferenced comments on the web. The onSubmit Event Handler is is used to execute specified JavaScript code whenever the *user* submits a form. I believe the problem you have is that Javascript aclling the submit() function is *not* the same as the user submitting the form. Thus the onSubmit handler is not invoked. In fact, this is why you calling submit() in your onSubmit handler does not cause an infinite loop. The resolution would be an explicit call to formvalidation() ... something like: a class="save_menu" href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; formvalidation(document.Detail_Screen) && document.Detail_Screen.submit();">Update</>a>- Hide quoted text - - Show quoted text - |
#12
| |||
| |||
|
|
Here you go, and thanks!! function formvalidation(thisform) { * * if (emptyvalidation(thisform.CustName.value,"Customer Name is empty")==false) {thisform.CustName.focus(); return false;}; * * if (emailvalidation(thisform.CustEmail.value,"Illegal E- mail")==false) {thisform.CustEmail.focus(); return false;}; * * if (thisform.CellPhone.value==null || thisform.CellPhone.value=="" || thisform.CellPhone.value==" ") { * * * *thisform.CellPhone.value="000-000-0000"; * * } else { * * * *if (phonevalidation(thisform.CellPhone.value,"Please enter a valid cell phone")==false) { * * * * * thisform.CellPhone.focus(); return false; * * * *}; * * }; * * thisform.submit(); } Change "thisform.submit()" to "return true" However, Reading you original post again, you wrote: *> <a class="save_menu" * href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; *> * * document.Detail_Screen.submit();">Update</>a [snip] *> At the end of the javascript validation routine, we have this: * *> thisform.submit(); * *> So, the form seems to submit, but not the way we want it to. *We want *> it to execute the validation routine first. So, I think you're saying "Why isn't validation performed when the user clicks on Update?" So, I believe this is an accurate description of what's happening. I've looked for something to back it up, but all I can find are unreferenced comments on the web. The onSubmit Event Handler is is used to execute specified JavaScript code whenever the *user* submits a form. I believe the problem you have is that Javascript aclling the submit() function is *not* the same as the user submitting the form. Thus the onSubmit handler is not invoked. In fact, this is why you calling submit() in your onSubmit handler does not cause an infinite loop. The resolution would be an explicit call to formvalidation() ... something like: a class="save_menu" href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; formvalidation(document.Detail_Screen) && document.Detail_Screen.submit();">Update</>a>- Hide quoted text - - Show quoted text - |
#13
| |||
| |||
|
|
Here you go, and thanks!! function formvalidation(thisform) { * * if (emptyvalidation(thisform.CustName.value,"Customer Name is empty")==false) {thisform.CustName.focus(); return false;}; * * if (emailvalidation(thisform.CustEmail.value,"Illegal E- mail")==false) {thisform.CustEmail.focus(); return false;}; * * if (thisform.CellPhone.value==null || thisform.CellPhone.value=="" || thisform.CellPhone.value==" ") { * * * *thisform.CellPhone.value="000-000-0000"; * * } else { * * * *if (phonevalidation(thisform.CellPhone.value,"Please enter a valid cell phone")==false) { * * * * * thisform.CellPhone.focus(); return false; * * * *}; * * }; * * thisform.submit(); } Change "thisform.submit()" to "return true" However, Reading you original post again, you wrote: *> <a class="save_menu" * href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; *> * * document.Detail_Screen.submit();">Update</>a [snip] *> At the end of the javascript validation routine, we have this: * *> thisform.submit(); * *> So, the form seems to submit, but not the way we want it to. *We want *> it to execute the validation routine first. So, I think you're saying "Why isn't validation performed when the user clicks on Update?" So, I believe this is an accurate description of what's happening. I've looked for something to back it up, but all I can find are unreferenced comments on the web. The onSubmit Event Handler is is used to execute specified JavaScript code whenever the *user* submits a form. I believe the problem you have is that Javascript aclling the submit() function is *not* the same as the user submitting the form. Thus the onSubmit handler is not invoked. In fact, this is why you calling submit() in your onSubmit handler does not cause an infinite loop. The resolution would be an explicit call to formvalidation() ... something like: a class="save_menu" href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; formvalidation(document.Detail_Screen) && document.Detail_Screen.submit();">Update</>a>- Hide quoted text - - Show quoted text - |
#14
| |||
| |||
|
|
On Jun 1, 4:53 pm, Dan Rumney <danrum... (AT) warpmail (DOT) net> wrote: FORM name='Detail_Screen' action="savedata.php" METHOD="POST" onsubmit='return formvalidation(this)' The problem is that the formvalidation routine is not being fired. I'm at a loss here. Can anyone help us with this? At the end of the javascript validation routine, we have this: thisform.submit(); formvalidation should return TRUE or FALSE, depending on whether the form's content is valid, or not. JavaScript will type convert the return value of the onsubmit handler to be a boolean. [...] |
#15
| |||
| |||
|
|
On Jun 1, 9:49 pm, Dan Rumney <danrum... (AT) 77617270mail (DOT) net> wrote: Here you go, and thanks!! function formvalidation(thisform) { if (emptyvalidation(thisform.CustName.value,"Customer Name is empty")==false) {thisform.CustName.focus(); return false;}; if (emailvalidation(thisform.CustEmail.value,"Illegal E- mail")==false) {thisform.CustEmail.focus(); return false;}; if (thisform.CellPhone.value==null || thisform.CellPhone.value=="" || thisform.CellPhone.value==" ") { thisform.CellPhone.value="000-000-0000"; } else { if (phonevalidation(thisform.CellPhone.value,"Please enter a valid cell phone")==false) { thisform.CellPhone.focus(); return false; }; }; thisform.submit(); } Change "thisform.submit()" to "return true" However, Reading you original post again, you wrote: a class="save_menu" href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; document.Detail_Screen.submit();">Update</>a [snip] At the end of the javascript validation routine, we have this: thisform.submit(); So, the form seems to submit, but not the way we want it to. We want it to execute the validation routine first. So, I think you're saying "Why isn't validation performed when the user clicks on Update?" So, I believe this is an accurate description of what's happening. I've looked for something to back it up, but all I can find are unreferenced comments on the web. The onSubmit Event Handler is is used to execute specified JavaScript code whenever the *user* submits a form. I believe the problem you have is that Javascript aclling the submit() function is *not* the same as the user submitting the form. Thus the onSubmit handler is not invoked. In fact, this is why you calling submit() in your onSubmit handler does not cause an infinite loop. The resolution would be an explicit call to formvalidation() ... something like: a class="save_menu" href="javascript:document.Detail_Screen.action='sa vedata.php?screen=EDIT'; formvalidation(document.Detail_Screen) && document.Detail_Screen.submit();">Update</>a>- Hide quoted text - - Show quoted text - Hi Dan, Your suggestion seems to work. I had to change a few things. But when I submit the form, it something fails the validation, it gives the proper error message, but then a new page appears with only the word 'false' on it........ |
|
On another note, I do not understand why sometimes I can refer to a parameter by name, and other times I need parameter.value......... |
![]() |
| Thread Tools | |
| Display Modes | |
| |