Solved

Input mask for text box in webpage

Posted on 1998-12-23
6
269 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 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 position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

920 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

15 Experts available now in Live!

Get 1:1 Help Now