Solved

Input mask for text box in webpage

Posted on 1998-12-23
6
268 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:gen101298
Comment Utility
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
Comment Utility
What browser? Could you submit your code?
0
 

Author Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now