I know the feeling of frustration when you are able to do something very easily in Access but simply can not do it in Interdev. You will enjoy Interdev once you get the hang of it but it will take some getting used to.
I was never able to find an easy to implement phone number formating option. I eventually just added space to my db field and asked users to format the phone number themselves. I know this is not the most user friendly option available but it does allow for people to format the number how they want.
Keep your chin up it gets better LOL
Crystal
crystalized_s@yahoo.com
I recently was able to fomat my DTC text box that was bound to a datetime field: Here's what I did:
I placed the following code into the OnChange event of my DTC text box (txtDate).
txtDate.value=FormatDateTime(txtDate.value,2)
This formats it as follows: mm\dd\yy
The problem I'm having now is that after I use the OnChange event I loose focus of the control. Therefore, I can't continue to tab to the next control.
Formatting can occur in many places (server and client). And for text-boxes, the formatting may need to be removed/altered when storing back to the database. ASP.NET is much better in this area (well, most areas to be honest).
To format data going into a textbox, do this to the variable before assignment to the textbox.
When the user modifies the text, you need to use some CLIENT-SIDE javascript code.
For a hand-built INPUT box, you just add
onblur="myFormatFunction(this)"
onfocus="myUnFormatFunction(this)"
For a DTC, you need to 'advise' these events to each textbox
in the thisPage_onenter method:
The "dummy" bit is meant to be the name of a Server-Side function - but we do not want it to go that far. So how do we prevent a Server Round-Trip?
Add a Client-Side code block with the following:
function thisPage_onbeforeserverevent(strObj, strEvt) {
if (strObj == "txtDate" {
if (strEvt=="onblur" {
myFormatFunction(document.thisForm.txtDate);
thisPage.cancelEvent = true
}
if (strEvt=="onfocus" {
myUnFormatFunction(document.thisForm.txtDate);
thisPage.cancelEvent = true
}
}
}
Note1: The parameters (strObj, strEvt) are not added by VisualInderdev if you double-click this event in the Script Outline View.
Note2: VisualInterdev does not pop-up the DTC textbox names - but they ARE valid. So just spell them correctly!
You could put the format / unformat functions in a separate javascript file that you include in the client page.
<script language="JavaScript"
src="../include/FormatFunctions.js">
</script>
You would need similar functions on the server-side code too. You would include them as
<!--#INCLUDE FILE="../include/FormatFunctions.asp"-->
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.