Batch card Time Validation

This commit is contained in:
velz2020 2018-02-07 20:26:56 +05:30
parent e7352c31f0
commit b7184f7a66
2 changed files with 37 additions and 40 deletions

View File

@ -529,24 +529,32 @@ var stop = $('#maintenance_time_to').val();
if(start != '' && stop != '')
{
if(start.length != 5 || stop.length != 5)
{
if(start.length != 5){
alert('Please Enter Time in 24 Hrs Format.If time is 9:25,Feed like 09:25');
document.getElementById('maintenance_time_from').value = '';
document.getElementById('maintenance_time_to').value = '';
document.getElementById('maintenance_time_from').value="";
setTimeout(function(){
$('#maintenance_time_from').focus();},0
);
return false;
}
if(stop.length != 5){
alert('Please Enter Time in 24 Hrs Format.If time is 9:25,Feed like 09:25');
document.getElementById('maintenance_time_to').value="";
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
return false;
}
var atime = '';
start = start.split(":");
stop = stop.split(":");
if(isNaN(start[0]) || isNaN(start[1]) )
if(isNaN(start[0]) || isNaN(start[1]) || parseFloat(start[0]) > 24 || parseFloat(start[1]) > 60)
{
alert("please Enter Valid Time");
document.getElementById('maintenance_time_from').value = '';
@ -557,7 +565,7 @@ if(start != '' && stop != '')
}
if(isNaN(stop[0]) || isNaN(stop[1]))
if(isNaN(stop[0]) || isNaN(stop[1]) || parseFloat(stop[0]) > 24 || parseFloat(stop[1]) > 60)
{
alert("please Enter Valid Time");
document.getElementById('maintenance_time_to').value = '';
@ -568,20 +576,13 @@ if(start != '' && stop != '')
}
if((start[0] > stop[0]))
{
alert('Enter Valid Time');
document.getElementById('maintenance_time_to').value = '';
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
return false;
}
if((start[1] > stop[1]))
{
alert('Enter Valid Time');
document.getElementById('maintenance_time_to').value = '';
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
@ -608,8 +609,6 @@ if(start != '' && stop != '')
//console.log(atime);
$('#maintenance_total_hrs').val((atime));
}
}
</script>

View File

@ -524,8 +524,7 @@ function keyValidate(e)
}
}
function calculateTime()
function calculateTime()
{
var start = $('#maintenance_time_from').val();
@ -537,24 +536,32 @@ var stop = $('#maintenance_time_to').val();
if(start != '' && stop != '')
{
if(start.length != 5 || stop.length != 5)
{
if(start.length != 5){
alert('Please Enter Time in 24 Hrs Format.If time is 9:25,Feed like 09:25');
document.getElementById('maintenance_time_from').value = '';
document.getElementById('maintenance_time_to').value = '';
document.getElementById('maintenance_time_from').value="";
setTimeout(function(){
$('#maintenance_time_from').focus();},0
);
return false;
}
if(stop.length != 5){
alert('Please Enter Time in 24 Hrs Format.If time is 9:25,Feed like 09:25');
document.getElementById('maintenance_time_to').value="";
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
return false;
}
var atime = '';
start = start.split(":");
stop = stop.split(":");
if(isNaN(start[0]) || isNaN(start[1]) )
if(isNaN(start[0]) || isNaN(start[1]) || parseFloat(start[0]) > 24 || parseFloat(start[1]) > 60)
{
alert("please Enter Valid Time");
document.getElementById('maintenance_time_from').value = '';
@ -565,7 +572,7 @@ if(start != '' && stop != '')
}
if(isNaN(stop[0]) || isNaN(stop[1]))
if(isNaN(stop[0]) || isNaN(stop[1]) || parseFloat(stop[0]) > 24 || parseFloat(stop[1]) > 60)
{
alert("please Enter Valid Time");
document.getElementById('maintenance_time_to').value = '';
@ -576,20 +583,13 @@ if(start != '' && stop != '')
}
if((start[0] > stop[0]))
{
alert('Enter Valid Time');
document.getElementById('maintenance_time_to').value = '';
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
return false;
}
if((start[1] > stop[1]))
{
alert('Enter Valid Time');
document.getElementById('maintenance_time_to').value = '';
setTimeout(function(){
$('#maintenance_time_to').focus();},0
);
@ -616,8 +616,6 @@ if(start != '' && stop != '')
//console.log(atime);
$('#maintenance_total_hrs').val((atime));
}
}
</script>