Showing posts with label Javascript/JQuery. Show all posts
Showing posts with label Javascript/JQuery. Show all posts
Monday, February 8, 2016
Tuesday, May 19, 2015
Monday, February 11, 2013
Wednesday, January 2, 2013
Thursday, December 27, 2012
Tuesday, October 30, 2012
Javascript trim function
Function trim (myString) { return myString.replace(/^s+/g,'').replace(/s+$/g,'') }
Monday, October 29, 2012
Textbox accept digits
script language="javascript" type="text/javascript">
function CheckNumeric(e) {
if (window.event) // IE
{
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
}
else { // Fire Fox
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
</script>
<input type="text" onKeyPress="CheckNumeric(event)" />
function CheckNumeric(e) {
if (window.event) // IE
{
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
}
else { // Fire Fox
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
function IsNumeric(sText) { var ValidChars = "0123456789."; //loop through the string passed in, iif its in the validchars list, continue, otherwise, return false for(i = 0; i < sText.length; i++) { if(ValidChars.indexOf(sText.charAt(i)) == -1) { return false; } } return true; }
function validateNumerical(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>
<input type="text" onKeyPress="CheckNumeric(event)" />
Thursday, October 25, 2012
Tuesday, October 16, 2012
Print only a part of the page
<div id="printableArea">
<h1>Print me</h1>
</div>
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
==========================================================================
using frames
==========================================================================
<html> <head> <title>Print Test Page</title> <script> printDivCSS = new String ('<link href="myprintstyle.css" rel="stylesheet" type="text/css">') function printDiv(divId) { window.frames["print_frame"].document.body.innerHTML=printDivCSS + document.getElementById(divId).innerHTML; window.frames["print_frame"].window.focus(); window.frames["print_frame"].window.print(); } </script> </head> <body> <h1><b><center>This is a test page for printing</center></b><hr color=#00cc00 width=95%></h1> <b>Div 1:</b> <a href="javascript:printDiv('div1')">Print</a><br> <div id="div1">This is the div1's print output</div> <br><br> <b>Div 2:</b> <a href="javascript:printDiv('div2')">Print</a><br> <div id="div2">This is the div2's print output</div> <br><br> <b>Div 3:</b> <a href="javascript:printDiv('div3')">Print</a><br> <div id="div3">This is the div3's print output</div> <iframe name="print_frame" width="0" height="0" frameborder="0" src="about:blank"></iframe> </body> </html>
Friday, December 30, 2011
Monday, April 25, 2011
Subscribe to:
Posts (Atom)