Can this code be changed to this.
If click INPUT (active) then "-" coming out.. If INPUT not have number then "-" is hidden... (click anywhere and can delete manual?)
If is -20 then can delete all -20 Now is empty (but input is active) and starting typing 30 and minus comes with the number.
I don't know it's possible.
My script don't like just - -20 (some number) or empty
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var specialKeys = new Array();
specialKeys.push(8);
specialKeys.push(9);
specialKeys.push(46);
specialKeys.push(36);
specialKeys.push(35);
specialKeys.push(37);
specialKeys.push(39);
function IsNumeric(e) {
if (e.keyCode === 46 &&
e.target.value.split(/\.|,/).length >= 2) {
return false;
}
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
return ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90)
|| keyCode == 32 || keyCode == 44 || keyCode == 46
|| (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
}
function ReplaceComma(ele, evt) {
ele.value = ele.value.replace(',', '.').replace('.,', '.').replace(',.', '.');
if (ele.value.split('.').length > 2) {
ele.value = ele.value.split('.').slice(0, 2).join('.')
}
}
function doCheck(id, evt) {
var temp = parseInt($(id).val());
if (isNaN(temp)) {
$(id).val('-');
}
$(id).val($(id).val());
}
</script>
<input type="text" value="-" maxlength="70" id="fmargin" onkeypress="return IsNumeric(event);"
onkeyup="ReplaceComma(this,event);doCheck('#fmargin', event);" />
</body>
</html>