<script>
$(document).ready(function(){
// onSelectSubmit get id & value
$('.OnChangeM').change(function(){
GID = $(this).attr('id'); //alert(GID);
if($("select[id='"+GID+"'] option:selected").val() != '')
$('#'+GID+'_txt').val($("select[id='"+GID+"'] option:selected").text());
$('#form'+GID+'').submit();
});
// OnSelect get id & value
$('.OnSelectM').change(function(){
GID = $(this).attr('id'); //alert(GID);
if($("select[id='"+GID+"'] option:selected").val() != '')
$('#'+GID+'_txt').val($("select[id='"+GID+"'] option:selected").text());
});
// Select ids, values
$("select").on("change", function(){
var id = $(this).attr("id");
var id_val = $(this).val();
var id_txt = this.options[this.selectedIndex].text;
$("#"+id+"_txt").val(id_txt);
//alert(id+"---"+id_val+"---"+id_txt);
})
// Selects all ids, values
$(".mselect").change(function(){
var str_ids = str_vals = "";
$("select option:selected").each(function(){
str_ids += $(this).val() + ",";
str_vals += $(this).text() + ",";
});
$(".mselect_ids").val(str_ids);
$(".mselect_vals").val(str_vals);
}).trigger("change");
// Select all checkboxes
$("#ckbCheckAll").click(function () {
$(".checkBoxClass").prop('checked', $(this).prop('checked'));
});
//autocomplete to off for all date input
$( document ).on( 'focus', '.dt', function(){
$(this).attr( 'autocomplete', 'off' );
});
$('.numeric').keyup(function(e){
if(/\D/g.test(this.value)){
// Filter non-digits from input value.
this.value = this.value.replace(/\D/g, '');
}
});
$('input[type="text"]').keyup(function(e){
// Filter single quote from input value.
this.value = this.value.replace( /[\'\"]/g, ' ');
});
$('textarea').keyup(function(e){
// Filter single quote from input value.
this.value = this.value.replace( /[\'\"]/g, ' ');
});
$(".allow_numeric").on("input", function(evt){ // Allow only numeric values
var self = $(this);
self.val(self.val().replace(/[^\d].+/, ""));
if((evt.which < 48 || evt.which > 57)){
evt.preventDefault();
}
});
$(".allow_decimal").on("input", function(evt){ // Allow numeric values with decimal
var self = $(this);
self.val(self.val().replace(/[^0-9\.]/g, ''));
if((evt.which != 46 || self.val().indexOf('.') != -1) && (evt.which < 48 || evt.which > 57)){
evt.preventDefault();
}
});
});
</script>
0 Comments