Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input masks!!

Status
Not open for further replies.

davesmith

IS-IT--Management
Apr 2, 2001
31
IE
I'm trying to enter fields in a certain fashion, one being (although not the only one) sort codes for client bank details.

The field should contain a 6 character record, i.e. being 141265.
This is then displayed in the for as 14-12-65, how!!!

And i need it to be entered in this fashion too, yet to record only the six digits.

As i've said before, i'm a cross-over Access coder, this was easily done in that, i'm at a loss in this (and i think my boss is booking me in for a roasting!!, these deadlines!!)

Cheers

Dave
 
Well once you have the data 14-12-65 in the text box,
you can replace the "-" with nothing:

strText = Replace(textbox.value, "-", "")

and save "strText" (which now looks like "141265")to your database. You can also do some validations to make sure the length is right, not null, etc.
 
Shtop, Shtop, We have a misunderstanding.

I want all i want to know is how to accept/display data in a certain format.

In access i would go into the Input Mask and type (for this same code 12-12-12)

00-/00-/00, this would put the number in the field as 121212 but would accept entry 121212 and split it as its entered with -,

Just like if someone was entering a date but you were saving it as text, such as 14102000, you can do it so it shows as 14/10/2000, But this too, i do not know how to do (although i know it is possible).

Any help is appreciated, its not how the data is saved, but only how it appears on the screen.

Cheers

Dave
 
Hello,
In Access you have very nice tool for input mask.
In web page, you are on your own to do the masking.
You have to take care of everything - what user inputs, what events happened and so on.
See an exemplary code with JavaScript
<HTML>
<HEAD>
<script>
function propershow(val){
val = val.toString();
if (val.indexOf(&quot;/&quot;) == -1) {
document.forms[0].txtVal.value = val.substr(0,2) +&quot;/&quot; + val.substr(2,2) +&quot;/&quot; + val.substr(4,2)
}
}
</script>
</HEAD>

<BODY>
<form>
<input name=&quot;txtVal&quot; type=&quot;text&quot; onClick=&quot;propershow(this.value)&quot; onBlur=&quot;propershow(this.value)&quot; value=&quot;mm/dd/yy&quot;>
</form>
</BODY>
</HTML>

Play with it.
Also it would be helpful if you post yor quetsion in JavaScript forum.
D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top