Solved

Input mask for text box in webpage

Posted on 1998-12-23
6
274 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
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 …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

735 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