Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Input mask for text box in webpage

Posted on 1998-12-23
6
273 Views
Last Modified: 2010-04-09
I use FP98 to create my webpage.  By using ActiveX, I'm able to set an input mask on my text box.  But it will only show if I use IE to view it, not with netscape.  So, is there any other way that I can set input mask to text box that can be view in both IE and netscape?

My text box takes value like 1997/1998.  So, I want to set input mask _ _ _ _ / _ _ _ _

_ will take integer only.  
0
Comment
Question by:gen101298
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
rafistern earned 50 total points
ID: 1840990
This might be satisfactory:

<html>
<head>
      <script>
      function updateRealdate(){
            document.forms[0].realdate.value=document.forms[0].dummy1.value.substr(0,4)+"/"+document.forms[0].dummy2.value.substr(0,4);
            return true;
      }
      var xxxx="xxxx";
      </script>
</head>
<body>
<form>
<input type=text name="dummy1" size=4 onfocus="setTimeout('document.forms[0].dummy1.value=xxxx;document.forms[0].dummy1.select()',50);document.forms[0].dummy2.value='xxxx';">
 /
<input type=text name="dummy2" size=4 onfocus="setTimeout('document.forms[0].dummy2.value=xxxx;document.forms[0].dummy2.select()',50);">
<input type=text name="realdate">
<input type=submit onsubmit="updateRealdate()">
</form>
</body>
</html>

I have given you two seperate text fields. When you enter the first field it sets both of then to "xxxx" in order to show you how many digits to enter and selects the text. You then go on the second field. When you submit the form put onsubmit="updateRealdate()" in the submit button tag and the hidden field will be updated. The function automatically truncates the strings to four digits.
0
 

Author Comment

by:gen101298
ID: 1840991
To Rafistern, the sample u gave uses 2 text box, dummy1 and dummy2.  But what if I want only 1 textbox that shows xxxx/xxxx?
0
 
LVL 4

Expert Comment

by:rafistern
ID: 1840992
OK,

<input type=text name="date" size=4 onfocus="setTimeout('document.forms[0].date.value=xxxx/xxxx;document.forms[0].date.select()',50);">

But the minute you start typing the / will disappear.

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:gen101298
ID: 1840993
To Rafistern, when I run my webpage that contains the above codes that u gave in browser, it runs perfectly...but when I put the webpage in a frame in another webpage, the  code behaves well when it is run for the first time, but for the following times, the textbox will just blank out any data that I key in after I click the submit button except the '/'.  But if I don't click the submit button, but press Enter instead, it behaves well...what's wrong?  Is it something wrong with the setTimeout?  


0
 
LVL 4

Expert Comment

by:rafistern
ID: 1840994
What browser? Could you submit your code?
0
 

Author Comment

by:gen101298
ID: 1840995
I'm too tied up with other things now, but I'll let u see the code asap.  Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Understanding mobile browsers 9 84
"Pause" execution of javascript function for x miliseconds 2 45
Multiflying 2 Input Text On a Table 7 31
How to resize a div in html 3 35
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question