Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


pwaddles

113 posts

Master Geek


#19730 28-Feb-2008 12:09
Send private message

Sounds easy enough, but cause its for a webpage and not a windows form I cant run any process to validate text as its being typed.

My order entry screen takes a whole lot of measurements that are in the form 1.23.  I'd like my users to only need to enter 123 and have the formatting all taken care of for them, but have it update the textbox as they go.  I've had an extensive search on google and cant seem to find what I'm after. 

Everything has been developed in visual studio 2008 in vb.net.  First person to give me an answer that works can have $10 transfered into their bank account by leaving their bank acconut number.  Boy I hope this thread doesnt get shut down for this.

View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
chiefie
I iz your trusted friend
5877 posts

Uber Geek

Retired Mod
Trusted
Lifetime subscriber

  #113514 28-Feb-2008 12:24
Send private message

VBScript: output=round(input/100,2)

To use it on textbox on HTML (pseudo-AJAX). Employ the technique of using "onchange" to call a javascript to make the rounding.

Alternatively, the user fill it in in cents (123 cents = $1.23) then submit away and on the server end, it gets calculated and processed.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 




pwaddles

113 posts

Master Geek


  #113515 28-Feb-2008 12:27
Send private message

but how do I get that to do as I require? realtime formatting etc.

chiefie
I iz your trusted friend
5877 posts

Uber Geek

Retired Mod
Trusted
Lifetime subscriber

  #113516 28-Feb-2008 12:32
Send private message

you must decide where does this take place, and when entered/processed, does the server validate the calculation before it gets put into DB or wherever?

Also, another thing I learn with the appropriate accounting calculation is, hundred-fy the value, calculate it, then divide it by 100 again to get a more accurate rounding.

for example:

if to calculate the addition of 123.45 and 456.23. You first hundred-fy both of the values. 12345+45623=57968, then divide by 100, so it became 579.68. This may seem unncessary but when you have a lot of decimal places, the every little decimals count towards accounting accuracy.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 




pwaddles

113 posts

Master Geek


  #113518 28-Feb-2008 12:35
Send private message

takes place on the server, and when entered.  Dont want the users to have to push a button to recalc numbers or anything like that.

RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113519 28-Feb-2008 12:35
Send private message

If you want it done in realtime you'll need to use javascript to validate and reformat the input using the onKeyPress event of the textbox.

It's not terribly hard to do, you've probably just been googling for the wrong things.

RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113520 28-Feb-2008 12:38
Send private message

In fact, two seconds of googling lead me to this forum post where someone is wanting to do pretty much exactly the same thing:

http://forums.asp.net/p/1223093/2193368.aspx

More info here:
http://www.codeproject.com/KB/scripting/Form_field_input_mask.aspx

chiefie
I iz your trusted friend
5877 posts

Uber Geek

Retired Mod
Trusted
Lifetime subscriber

  #113521 28-Feb-2008 12:42
Send private message

I agreed. It isn't a hard bit of coding... Javascript for HTML realtime formatting.

When submitted to server, your best bet will be looking for accuracy and not calculation/formatting (right?)




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 


 
 
 

Move to New Zealand's best fibre broadband service (affiliate link). Free setup code: R587125ERQ6VE. Note that to use Quic Broadband you must be comfortable with configuring your own router.
pwaddles

113 posts

Master Geek


  #113522 28-Feb-2008 12:42
Send private message

I'd rather not use Java, want to keep it to VB.  if thats the only way to get it to go then I might just flag it.

RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113525 28-Feb-2008 12:49
Send private message

Note this is javascript and not Java (you might be just shorthanding, but just in case - the two are different languages). I'm not sure why you're not keen on javascript - it's the correct (read standard) solution for this problem, but thats up to you. It is possible to use VBScript to handle the onKeyPress event as well - however VBScript is only supported by IE so you'll lose cross browser compatibility.

If you're just not confident with writing javascript then consider using the asp.net ajax extensions along with the masked edit extender from the ajax control tool kit (which will produce javascript for you without you needing to deal with client side script).

signz
95 posts

Master Geek


  #113561 28-Feb-2008 15:07
Send private message


As above, if you want code to execute at the client end Javascript is the correct thing to use.  The main processing still takes place in VB code at the server end but the Javascript is used to validate and format stuff at the client end BEFORE it gets posted back to ASP.NET / server.

http://msdn2.microsoft.com/en-us/library/3hc29e2a.aspx

http://msdn2.microsoft.com/en-us/library/ms178207.aspx

DS

pwaddles

113 posts

Master Geek


  #113562 28-Feb-2008 15:09
Send private message

thanks but I dont want to use any javascripts.

signz
95 posts

Master Geek


  #113563 28-Feb-2008 15:12
Send private message


The point is that you MUST use client-side Javascript if you want stuff to happen AS THE USER TYPES.  VB.NET inside ASP pages only runs at the server so therefore the user needs to hit SUBMIT to send it to the server before your VB code sees it (and can act on it). 

The only code that can take action as the client types is stuff running inside the browser - Javascript, VBscript or a java applet. 

Javascript is the right choice here and not complex.


DS

chiefie
I iz your trusted friend
5877 posts

Uber Geek

Retired Mod
Trusted
Lifetime subscriber

#113566 28-Feb-2008 15:19
Send private message

you can't help those who are not willing to be helped.




Internet is my backyard...

 

«Geekzone blog: Tech 'n Chips Takeaway» «Personal blog: And then...»

 

Please read the Geekzone's FUG

 


pwaddles

113 posts

Master Geek


  #113570 28-Feb-2008 15:29
Send private message

Im thinking red jungle's and signz's suggestions of using a vbscript sounds good, keep it all the same flavour.  None of our target audience will be using firefox or opera or anything other than IE. 

RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113572 28-Feb-2008 15:35
Send private message

You'll find the code and syntax that you'll be using to implement this in VBScript is very similar to the Javascript needed (plus is pretty much provided for you in those links I posted).

It's the last time I'll try to convince you, but I urge you to look into using javascript instead - these days it's actually quite an elegant  and robust language thats worth knowing if you're going to be developing web sites or web applications.

 1 | 2
View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.