小编sat*_*mar的帖子

复制和粘贴时不允许文本框中的小数和文本值

我不想允许在文本框中输入、复制和粘贴十进制值和字母表。我可以输入负值。但是负号(" - ") 应该总是在开头。请看下面的小提琴。在这个小提琴中它不允许十进制值和字母表。但是,如果我像这样复制并粘贴“22.50”,它将采用十进制值。我怎么能限制这个。

我的要求,

1) 只允许数字(正数和负数)。

2)“ - ”符号应在开头。不允许在中间或某处。

3) 字母甚至不应该允许复制粘贴。

4)我可以复制粘贴数字,如“2222”和“-2222”。但不是字符和小数。

小提琴

var input = document.getElementById("myInput");

input.onkeypress = function(e) {    e = e || window.event;
    var charCode = (typeof e.which == "number") ? e.which : e.keyCode;

    // Allow non-printable keys
    if (!charCode || charCode == 8 /* Backspace */ ) {
        return;
    }

    var typedChar = String.fromCharCode(charCode);

    // Allow numeric characters
    if (/\d/.test(typedChar)) {
        return;
    }

    // Allow the minus sign (-) if the user enters it first …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

5
推荐指数
1
解决办法
2745
查看次数

以角度6动态添加div容器

如何以角度动态添加div容器?

请看我的HTML代码.每当我点击"添加"按钮时,一个新的div应该添加该按钮的左侧.动态地,它应该根据点击的方式添加多个容器.一切都应该横向加入.如果默认情况下它是更多的容器,它应该添加滚动并且它是统一的.任何人都可以帮我做到这一点angular 6.

#content{
    width:100%;
    height:90px;
    border:1px solid black;
}
#contentInside{
    width:100px;
    height:70px;
    margin:7px;
    border:1px solid black;
    display:inline-flex;
}
Run Code Online (Sandbox Code Playgroud)
<div id="content">
    <div id="contentInside">
    
    </div>
    <button (click)="add()">Add</button> 

</div>
Run Code Online (Sandbox Code Playgroud)

我是棱角分明的新人.请有人帮我这样做.

html css angular angular6

5
推荐指数
1
解决办法
1万
查看次数

如何以角度拖动和重新排序内容

我有5个不同的内容。我想将其拖动并重新排序在同一行中。我如何在角度 2、4、5 或 6 中执行此操作。如果有人知道,请帮助我执行此操作。

堆栈闪电战

angular angular5 angular6

3
推荐指数
1
解决办法
9221
查看次数

不允许在文本框中使用小数和字母值

我想在文本框中重写小数和alphabatic值.我只想在文本框中输入数字.并且不要复制和粘贴文本和十进制值.只想输入数字(0 o 9).我怎么能用javascript的jgeery正则表达式做到这一点.

小提琴

看到这个小提琴,这里一切正常.但箭头键不起作用.我无法向左和向右移动,如果我给(shift + home)或(shift + end)它不选择值.请帮帮我

 

 $(".allownumericwithoutdecimal").on("keypress keyup blur",function (event) {    
           $(this).val($(this).val().replace(/[^\d].+/, ""));
            if ((event.which < 48 || event.which > 57)) {
                event.preventDefault();
            }
        });
Run Code Online (Sandbox Code Playgroud)
 
    
 <span>Int</span>
<input type="text" name="numeric" class='allownumericwithoutdecimal'>
<div>Numeric values only allowed  (Without Decimal Point) </div>  
Run Code Online (Sandbox Code Playgroud)

做这个.

html javascript regex jquery

2
推荐指数
1
解决办法
5116
查看次数

如何在单击按钮的angularjs中调用alt + f4键

我要在单击按钮时关闭当前选项卡。如何在angularjs中手动调用Alt + F4

$scope.cancel = function (event) {
    var keycode = event.keycode;
};
Run Code Online (Sandbox Code Playgroud)
<button class="btn btn-outline-primary" ng-click="cancel($event);">OK</button>
Run Code Online (Sandbox Code Playgroud)

在此取消功能内,我想调用Alt键和F4键。

  • )每当我单击“确定”按钮时,都需要关闭当前选项卡。

window.close()$window.close()没有任何效果。所以我想这样走。请任何人帮助我实现这一目标。

html javascript angularjs

-1
推荐指数
1
解决办法
64
查看次数

标签 统计

html ×4

javascript ×3

angular ×2

angular6 ×2

css ×2

jquery ×2

angular5 ×1

angularjs ×1

regex ×1