a little javascript regex help

MasterMax1313

New Member
Messages
84
Reaction score
0
Points
0
i have what seems to be a regex that should work, but isn't.

Code:
var result = /[0-9]+/g.exec(enteredTime);

input : 00:05

result: one value of 00. i've tested it on another javascript regex evaluator site which seems to work fine with the result of 00 and 05.

any help would be appreciated.

edit:

I've managed to come up with another solution, with the help of a friend

Code:
var enteredTime = document.getElementById('Blind_Time').value;
	var result = enteredTime.match(/^(\d\d):(\d\d)$/g);
	if(result)
	{
		var result = enteredTime.match(/[0-9]+/g); 
		blind_hours = parseInt(result[0]);
		blind_minutes = parseInt(result[1]);
		time_to_next.setHours(blind_hours, blind_minutes, 0, 0);
		
	}
	else
	{
		alert("Time must be in the hh:mm format");
	}
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Is "Blind_Time" a form input in a form or by itself?
 
Last edited:

federico_casares

New Member
Messages
49
Reaction score
0
Points
0
Probably you should use the exec method inside a loop...

while(result = regex.exec(string) != null ) {
// do something with result
}
 
Top