你可以告诉我当按下回车键时如何将焦点转移到下一个字段?我使用dform插件(将JSON转换为表单).
我用Google搜索,但这不起作用.为什么我的重点不转移到下一个领域?
$(document).keypress(function(e) {
if(e.which == 13) {
// Do something here if the popup is open
alert("dd")
var index = $('.ui-dform-text').index(this) + 1;
$('.ui-dform-text').eq(index).focus();
}
});Run Code Online (Sandbox Code Playgroud)
*注意(来自评论):它还需要处理没有tabindex设置值的页面
有没有一种方法可以仅使用vanilla javascript从 url 读取图像文件?作为上下文,我正在构建一个简单的拖放图像上传器,我想我已经有了从 PC 读取文字文件的部分,但至于 URL,我该怎么做呢?示例: https: //imgur.com/upload
我希望能够从谷歌拖动图像并在拖放区中读取它。
https://codepen.io/Ryenra/pen/JjoyPaq
function dropEv(e) {
e.preventDefault();
e.stopPropagation();
}
function dragOver(e) {
document.getElementById('box').style = "opacity: 0.9;";
}
function dragLeave(e) {
document.getElementById('box').style.removeProperty('opacity');
}
function receiveFile(e) {
let temp = e.dataTransfer.files;
if(temp.length && temp[0].type.match(/image.*/)){
document.getElementById('eText').textContent = temp[0].name;
}else{
alert('nv');
}
}Run Code Online (Sandbox Code Playgroud)
html,body{
height: 100%
}
#content {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#box{
width: 350px;
height: 300px;
background: repeating-linear-gradient(
-55deg,
#222,
#222 10px,
#333 10px,
#333 20px …Run Code Online (Sandbox Code Playgroud)在此代码中,空电子邮件验证有效,但电子邮件类型验证无效。如果插入有效的电子邮件地址,电子邮件类型验证仍会显示“无效电子邮件”消息。
new TextFormField(
decoration: new InputDecoration(
labelText: 'Email'
),
validator: (value){
if (value.isEmpty) {
return 'Email is required';
}
if(!value.contains(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')){
return 'Invalid Email';
}
return null;
},
)
Run Code Online (Sandbox Code Playgroud)
可能错误的行是:
if(!value.contains(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'))
Run Code Online (Sandbox Code Playgroud)