/    Sign up×
Community /Pin to ProfileBookmark

‘Start Time <= End Time’ Validation HELP!

I have created an asp page that has the following details:

[COLOR=DarkRed]frmStaDevAddEdit = form name

cboHourStart = drop-down menu for Start Time Hours (08 – 17)
cboMinuteStart = drop-down menu for Start Time Minutes (00 – 05 – 10- 15 – 20 …and so on to 55 )
txtTimeStart = Input Name (holds cboHourStart + cboMinuteStart)

cboHourEnd= drop-down menu for End Time Hours (08 – 17)
cboMinuteEnd = drop-down menu for End Time Minutes (00 – 05 – 10- 15 – 20 …and so on to 55 )
txtTimeEnd = Input Name (holds cboHourEnd + cboMinuteEnd)[/COLOR]
I need some Javascript validation, that looks at the txtTimeStart & txtTimeEnd, & checks that txtTimeEnd is not the same or smaller than txtTimeStart.

So far I have

[COLOR=DarkRed]if(frmStaDevAddEdit.txtTimeStart.value == frmStaDevAddEdit.txtTimeEnd.value){
alert( “End time cannot be the same or earlier then the Start time!”);
return false;
}else{
//carry on[/COLOR]

I would be very grateful if anyone could tell me how to adapt my code

I hope this all makes sense.

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JuuitchanApr 26.2005 — I take it that you are storing these times as strings, not as numerics.

Since the strings are of equal length, why not just use a string comparison?

Why has this idea not already occurred to you?
Copy linkTweet thisAlerts:
@bonus_authorApr 26.2005 — sorry, not sure what you mean...

Im pretty new to JavaScript
×

Success!

Help @bonus_ 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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