/    Sign up×
Community /Pin to ProfileBookmark

Select part of text from textbox

Hi,

I’m having a big problem. I have a textbox with a date (format dd/MM/yyyy)
What i want is this:

When the users clicks in the textbox, i want the textbox to select the first two items (dd), so the user can input the days. When that’s done, i want the textbox to select MM, and after that, i want the textbox to select yyyy.

Is there any possibility to do this? I already tried this snippet:

[CODE]function selectSomeText(element){
var workRange=document.selection.createRange();
var allRange=element.createTextRange();
workRange.setEndPoint(“StartToStart”,allRange);
workRange.select();
alert(“Click Event Fired”);
}[/CODE]

But this will select the left part from where my cursor stands…
Any help plz?

Tnx!!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @birre 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.21,
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,
)...