Click to See Complete Forum and Search --> : Textbox Formatting


RobDog888
October 18th, 2006, 02:01 PM
I need to format some textboxes with various formats. Since there is no VB 6 Masked Textbox control or function I believe the solution would be a JavaScript on. As the user types I need the textbox to retain the format.

For ex.

Phone number format:
(###) ###-####

Date format:
mm/dd/yyyy

Etc.

Also, the textboxes in question are all dynamically created and added to an aspx table control.

Thanks

jasonli
October 18th, 2006, 02:28 PM
Check http://www.codeproject.com/jscript/Form_field_input_mask.asp.

RobDog888
October 18th, 2006, 03:28 PM
That is some easier js to understand :)

Still, I added the js file as an includes file but still cant get it to execute without error.


'<DOB>
txtText = New TextBox
txtText.EnableViewState = True
txtText.Width = Unit.Pixel(115)
txtText.ID = "DOB1"
txtText.MaxLength = 10
txtText.Text = "1/1/1900"
txtText.Attributes.Add("onKeyUp", "<script language='JavaScript' type='text/javascript'>return mask(this.value,this,'3,6','-');</script>")
Me.Table2.Rows(3).Cells(2).Controls.Add(txtText)
txtText = Nothing

Also, the script is not functional if they enter in single digit dates as in 1-1-2006. It will format it wrong.

Got another script link? :)

RobDog888
October 22nd, 2006, 03:29 PM
I received another link on VBF and its a great script. Only problem is the dynamic control creation does not allow the js code to locate the controls until the page is completely loaded or a second postback is performed.

How do I get around this?

Script reference thread at VBF - http://vbforums.com/showthread.php?t=433579

RobDog888
October 23rd, 2006, 07:01 PM
If the controls are added but the containing table's row be set to .Visible = False be an issue? Shouldnt it act like a hidden input control?