Solved

Input mask for text box in webpage

Posted on 1998-12-23
6
275 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Find out what you should include to make the best professional email signature for your organization.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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