Preventing multi-submitting in html form with JQuery

<!DOCTYPE html>
<html lang=”en” class=”ie8″>
<html lang=”en”>
<head>
</head>
<body>
<form method=”POST” action=”http://localhost:8080/township/store&#8221; accept-charset=”UTF-8″ id=”townshipForm”>
<input type=”submit” name=”submit” value=”ADD” class=”btn_submit form-control btn-primary”>

$(document).ready(function() {
//Start Validation for Township Entry and Edit Form
$(‘#townshipForm’).validate({
rules: {
name : ‘required’
},
messages: {
name : ‘Township Name is required’
},
// Make sure the form is submitted to the destination defined
// in the “action” attribute of the form when valid
submitHandler: function(form) {
$(“.btn_submit”).attr(‘disabled’,’disabled’);
form.submit();
}
});
//End Validation for Township Entry and Edit Form

});

</body>
</html>

Advertisements

Editing value of readonly Text input

<!DOCTYPE html>
<html>
<head>
<script src=”http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js”&gt;
</script>
<script>

$(document).ready(function(){
$(‘#text_hid’).change( function () {
$(‘#text_hid’).val(‘TESTING’);
});

$(‘#bind_btn’).    click(function () {
$(‘#text_hid’).trigger(‘change’);
});
});
</script>
</head>
<body>

<h4>Editing value of readonly Text / Binding the OnChange event to Input readonly text</h4>

<input type=’text’ id=’text_hid’ readonly placeholder=”This is readonly text”>
<button id=’bind_btn’>Bind ‘Onchange’ Event</button>

</body>
</html>

Enable / Disable to datetime picker JQuery

At HMTL

 

<div id=”start_dateDiv”>
<span>Start Date:</span>
<input type=”text” name=”str_start_date” id=”str_start_date” style=”width: 170px”/>
</div>
<script type=”text/javascript”>
$(function() {
$( “#str_start_date” ).datepicker({
dateFormat: ‘dd M yy’,
changeMonth: true,
changeYear: true,
showOn: “button”,
buttonImage: “/images/icon_calendar.gif”,
buttonImageOnly: true,
altField: “#report_start_date”,
altFormat: “yy-mm-dd”,
yearRange: “-10:+10”
});
});
</script>

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
At Javascript

function Change(){
$(“#start_dateDiv”).children().prop(‘disabled’,false);
$(“#start_dateDiv”).children(“img”).fadeIn(“slow”);

OR
$(“#start_dateDiv”).children().prop(‘disabled’,true);
$(“#start_dateDiv”).children(“img”).fadeOut(“slow”);
}
_________________________________________________

HTML Validation

Knowledge Sharing

Integer Filter for Input Textbox in HTML

<!doctype html>
<html>
<head>
</head>
<body>
<input type=”text” onkeypress=”if(this.value.match(/\D/)) this.value=this.value.replace(/\D/g,”)”
onkeyup   =”if(this.value.match(/\D/)) this.value=this.value.replace(/\D/g,”)” name=”test” id=”test”  style=”width: 200px;” />
</body>
</html>

reference : http://www.javascripter.net/faq/keyboardinputfiltering.htm


Integer Filter for Input Textbox in HTMLwith JQUERY

<!doctype html>
<html>
<head>
</head>
<body>
<input type=”text” id=”test” name=”test” style=”width: 200px;” />
<input type=”text” id=”test2″ name=”test2″ style=”width: 200px;” />


$(document).ready(function() {
$(“#test,#test2”).keydown(function (event) {
// Prevent shift key since its not needed
if (event.shiftKey == true) {
event.preventDefault();
}
// Allow Only: keyboard 0-9, numpad 0-9, backspace, tab, left arrow, right arrow, delete
if ((event.keyCode >= 48 && event.keyCode = 96 && event.keyCode // Allow normal operation
} else {
// Prevent the rest
event.preventDefault();
}
});

});

</body>
</html>


View original post

HTML Validation

Integer Filter for Input Textbox in HTML

<!doctype html>
<html>
<head>
</head>
<body>
<input type=”text” onkeypress=”if(this.value.match(/\D/)) this.value=this.value.replace(/\D/g,”)”
onkeyup   =”if(this.value.match(/\D/)) this.value=this.value.replace(/\D/g,”)” name=”test” id=”test”  style=”width: 200px;” />
</body>
</html>

reference : http://www.javascripter.net/faq/keyboardinputfiltering.htm


Integer Filter for Input Textbox in HTML with JQUERY

<!doctype html>
<html>
<head>
</head>
<body>
<input type=”text” id=”test” name=”test” style=”width: 200px;” />
<input type=”text” id=”test2″ name=”test2″ style=”width: 200px;” />

<script>
$(document).ready(function() {
$(“#test,#test2”).keydown(function (event) {
// Prevent shift key since its not needed
if (event.shiftKey == true) {
event.preventDefault();
}
// Allow Only: keyboard 0-9, numpad 0-9, backspace, tab, left arrow, right arrow, delete
if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46) {
// Allow normal operation
} else {
// Prevent the rest
event.preventDefault();
}
});

});
</script>

</body>
</html>