/    Sign up×
Community /Pin to ProfileBookmark

i have a text field..which accepts date in dd/mm/yyyy format only..if user enter fake entry..then it displays error and clear the field.. using onblur event..

<input name=”past” type=”text” name=”date”>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 24.2005 — ok, you have that... So, which is your problem with it?
Copy linkTweet thisAlerts:
@CharlesJan 24.2005 — [font=monospace]<script type="text/javascript">

<!--

Date.prototype.toDDMMYYYYString = function () {return isNaN (this) ? 'NaN' : [this.getDate() > 9 ? this.getDate() : '0' + this.getDate(), this.getMonth() > 8 ? this.getMonth() + 1 : '0' + (this.getMonth() + 1), this.getFullYear()].join('/')}

Date.fromDDMMYYYY = function (s) {return (/^(dd?)D(dd?)D(d{4})$/).test(s) ? new Date(RegExp.$3, RegExp.$2 - 1, RegExp.$1) : new Date (s)}

String.prototype.isDate = function () {return this == Date.fromDDMMYYYY(this).toDDMMYYYYString()}

// -->

</script>

<input onchange="if (!this.value.isDate()) {alert(); this.value=''; this.focus()}" type="text">[/font]
×

Success!

Help @abhit_kumar 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...