/    Sign up×
Community /Pin to ProfileBookmark

Input popup with select?

I have a form that needs the user to enter a date (month and year). the way the page is setup, it has a text input and the user is instructed to enter the info in as MM/YYYY, but I still want to verify that is all correct and all the characters are numbers (minus the slash).

so i was thinking it might just be easier if a form the temporyily popped up in somewhat like a promt box and asked the user for the date using selects, thus saving me the trouble of having to validate the input.

I found [URL=http://www.w3schools.com/js/tryit.asp?filename=try_dom_window_popup]this[/URL] and it looks like i can put a form in the “innerHTML”. but the popup closes when you click out side of it and it also works in IE, but not firefox.

to post a comment
HTML

9 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 05.2006 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Date validation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
window.onload=function() {
var oInput=document.getElementsByTagName('input')[0].onblur=function() {checkIt(this);};
}

function checkIt(obj) {
var check = /[0|1]d/[1|2]d{3}/.test(obj.value);
alert('date is '+check);
}
</script>

</head>
<body>
<form action="#" name="form1">
<fieldset><legend>date form</legend>
<label title="MM/YYYY">date:<input type="text"></label>
</fieldset>
</form>
</body>
</html>
Copy linkTweet thisAlerts:
@TheIrishThugauthorMar 05.2006 — thank for the help
Copy linkTweet thisAlerts:
@TheIrishThugauthorMar 05.2006 — how would i have to set up the .test if i wanted to test to see if the year was between 1998 and 2006?
Copy linkTweet thisAlerts:
@FangMar 05.2006 — <script type="text/javascript">
window.onload=function() {
var oInput=document.getElementsByTagName('input')[0].onblur=function() {checkIt(this);};
}

function checkIt(obj) {
var check = /[0|1]d/[1|2]d{3}/.test(obj.value);
if( !( check && year(obj) ) ) {
alert('date is wrong');
}
}

function year(obj) {
var str=obj.value.split('/');
return (str[1]>=1998 && str[1]<=2006)? true : false;
}
</script>
Copy linkTweet thisAlerts:
@TheIrishThugauthorMar 06.2006 — my compiler says there is an javascript syntax error on the line:

var check = /[0|1]d/[1|2]d{3}/.test(obj.value);
Copy linkTweet thisAlerts:
@FangMar 06.2006 — There is no error there. Can you show the complete document?
Copy linkTweet thisAlerts:
@TheIrishThugauthorMar 07.2006 — ok here it is. i'm using AceHTML 6 Pro (trial edition) in case it matters. it says the error is a syntax error and then a warning about an expected ; clicking on the errors brings the cursor to right before the .test.

I had deleted some of the code so it would fit, but it's probly just better if u get the whole thing. so the page is [URL=http://www.visitthesaint.com/TourneySearch.html]here[/URL]

after you click submit it will get a page not found error cause i'm not done formating the page that gets called on the submit.
Copy linkTweet thisAlerts:
@FangMar 07.2006 — AceHTML 6 Pro gets it wrong. It may be confused by the fact that the javascript is outside the HTML. [URL=http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.visitthesaint.com%2FTourneySearch.html]Validate the document[/URL] and then see if AceHTML 6 Pro knows what it's doing.
Copy linkTweet thisAlerts:
@TheIrishThugauthorMar 09.2006 — Validated and AceHTML still doesn't like it. But I'm moving on because it appears to be working fine despite what Ace says.
×

Success!

Help @TheIrishThug spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...