javascript JS Bin //来源https://jsbin.com/kanukob

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript JS Bin //来源https://jsbin.com/kanukob相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <form action="/whatever" method="post" id="user-form">
    <input type="text" id="user">
    <input type="text" id="avatar-file">
    <button type="submit" id="submitButton">Submit</button>
    <br>
    <span id="user-error"></span>
  </form>
<script id="jsbin-javascript">
let form = document.getElementById('user-form');

form.addEventListener('submit', event => {
  let user = form.elements['user'];
  let userError = document.getElementById('user-error');
  let avatarFile = form.elements['avatar-file'];
  console.log(user.value, avatarFile.value);
  userError.textContent = 'Invalid entry';
  userError.style.color = 'red';
  user.style.borderColor = 'red';
  user.focus();
  event.preventDefault();
});
</script>



<script id="jsbin-source-javascript" type="text/javascript">let form = document.getElementById('user-form');

form.addEventListener('submit', event => {
  let user = form.elements['user'];
  let userError = document.getElementById('user-error');
  let avatarFile = form.elements['avatar-file'];
  console.log(user.value, avatarFile.value);
  userError.textContent = 'Invalid entry';
  userError.style.color = 'red';
  user.style.borderColor = 'red';
  user.focus();
  event.preventDefault();
});</script></body>
</html>
let form = document.getElementById('user-form');

form.addEventListener('submit', event => {
  let user = form.elements['user'];
  let userError = document.getElementById('user-error');
  let avatarFile = form.elements['avatar-file'];
  console.log(user.value, avatarFile.value);
  userError.textContent = 'Invalid entry';
  userError.style.color = 'red';
  user.style.borderColor = 'red';
  user.focus();
  event.preventDefault();
});

以上是关于javascript JS Bin //来源https://jsbin.com/kanukob的主要内容,如果未能解决你的问题,请参考以下文章

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/lituhib

html 相机模式 - JS Bin //来源https://jsbin.com/binoho