Sub txtFechaVencimiento_onblur()
If len(thisForm.txtFechaVencimiento.value)<> 10 and len(thisForm.txtFechaEfectividad.value)= 10 then
msgbox "El largo del campo 'Fecha de Vencimiento' debe ser de diez caracteres",,"Cálculo de Prima de Single Interest"
thisForm.txtFechaVencimiento.focus()
exit sub
elseif len(thisForm.txtFechaVencimiento.value)= 10 then
thisForm.txtTermino.value=round(datediff ("m",thisForm.txtFechaEfectividad.value,thisForm.txt FechaVencimiento.value) + (1/31))
I am not sure that onblur works in Netscape anyway.
You should always include document. before the form reference - again because of Netscape.
If len(document.thisForm.txtFechaVencimiento.value)...
Finally, you can perform validation when the form is submitted - either in the
FORM ... onsubmit= (return false to stop the submit)
or (if you use the Script Object Model) in the
function thisPage_onbeforeserverevent(i_strObject, i_strEvent) {
- you will need to add the i_strObject, i_strEvent parameters yourself. These will be filled with the name of the object and the event (eg 'pbSave' and 'onclick')
To prevent the form from submitting, you need to say
thisPage.cancelEvent = true;
In either of these methods, you can just call your _onblur function if you wish.
If I had a server-side function/sub called dummy(), then it would be called every time the txtFred textbox DTC lost its focus - not so helpful!
However, we can trap this server-event on the client, and prevent the server round-trip. You do this in the thisPage_onbeforeserverevent function (please add a PageObject DTC to you page first). The details of this were shown in my previous response.
Note: The 'advise' method of a DTC allows you to add ANY event signature to a form control. When the DTC generates the HTML for the control at runtime, it adds the 'advise' items to the HTML tag:
The _fireEvent bit causes a few things to occur, including the calling of the onbeforeserverevent - where you can call your routines.
If this DTC method seems horrid, well it is! However, it is really quite easy to modify the DTC code to make things much easier. Just edit the _ScriptLibrary\TEXTBOX.ASP and add a new property, called onblur, and in the display routine (near the bottom) output the onblur attribute if the onblur property is not blank. I can give you the full details if you wish.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.