Commit dc9e756b by Azhan Hannan

log pia 90 -> Block huruf dan simbol !@#$%^&*())_+-=[]\{}|;’:”,<>/?

Expectation: hanya bole key nombor decimal shj.
parent 559d7f38
......@@ -109,7 +109,7 @@
@endfor
@endif
<td>
<input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="" value={{$total}}>
<input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="readonly" value={{$total}}>
</td>
</tr>
@endforeach
......@@ -117,4 +117,93 @@
</table>
</form>
</div>
@endsection
\ No newline at end of file
@endsection
@push('script')
<script>
function onlynumber(evt)
{
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = /[0-9]|\./;
if( !regex.test(key) )
{
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
</script>
<script>
$().ready(function() {
});
function limiter(input,pid) {
var currenttotal = 0;
var all = 0;
if (input.value < 0) input.value = 0;
if (input.value > 24) input.value = 24;
// if( (input.value%1) > 0 && (input.value%1) <= 0.2 ) {
// input.value = Math.floor(input.value);
// }
// if( (input.value%1) > 0.2 && (input.value%1) <= 0.7 ) {
// input.value = Math.floor(input.value) + 0.5;
// }
// if( (input.value%1) > 0.7) {
// input.value = Math.ceil(input.value);
// }
input.value = parseFloat(parseFloat(input.value).toFixed(1));
for(var i = 0; i < 32; i++){
var value = 0;
var hourValue = document.getElementById('hour['+pid+']['+i+']');
if(hourValue){
hourValue = hourValue.value;
value = parseFloat(parseFloat(hourValue).toFixed(1));
// console.log(isNaN(value));
if(isNaN(value)){
value = 0;
}
if(typeof value === 'number'){
currenttotal += value;
}
}
}
// console.log("currenttotal --> " + currenttotal);
document.getElementById('total-'+pid).value = currenttotal;
// var y = 0;
// for(var j = 1; j < key+1; j++){
// var allid = document.getElementById('total-'+j);
// if (document.getElementById('total-'+j)) {
// y = document.getElementById('total-'+j).value;
// value = parseFloat(parseFloat(y).toFixed(1));
// // all += value;
// }
// }
// console.log(all);
// document.getElementById('all').value = all;
// document.getElementById('total-'+pid).value = currenttotal;
}
</script>
@endpush
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment