|
|
|
JavaScript Disable Space อยากทราบว่าถ้าต้องการให้ textbox ไม่สามารถเคาะวรรคได้เราจะใช่คำสั่งอะไรค่ะ. .. |
|
|
|
|
|
|
|
Code (JavaScript)
<script>
function RestrictSpace() {
if (event.keyCode == 32) {
event.returnValue = false;
return false;
}
}
</script>
</head>
<body>
<form id="form1">
<input type="text" name="txtName" onkeypress="return RestrictSpace()">
</form>
|
|
|
|
|
Date :
2013-01-16 21:19:57 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบไม่ทันพี่วิน
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!-- Get Google CDN's jQuery and jQuery UI with fallback to local -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.7.2.min.js"%3E%3C/script%3E'))</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>!window.jQuery.ui && document.write(unescape('%3Cscript src="js/jquery-ui-1.8.21.custom.min.js"%3E%3C/script%3E'))</script>
<script type="text/javascript">
$(document).ready(function(){
$('textarea').keypress(function(e) {
if (e.which === 32) {
$('#adf').css("display", "block");
return false;
}
setTimeout(function() {
$('#adf').slideUp('slow');
}, 5000);
});
});
</script>
</head>
<body>
<textarea></textarea>
<span id="adf" style="display:none; color:red">No space allowed and use comma to seperate</span>
</body>
</html>
|
|
|
|
|
Date :
2013-01-16 21:21:06 |
By :
pokultra |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จัดไปครับ
|
|
|
|
|
Date :
2013-01-16 21:23:41 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากเลยค่ะ
|
|
|
|
|
Date :
2013-01-16 21:31:59 |
By :
เมจิก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|