Skip to content

Instantly share code, notes, and snippets.

@imSmaity
Last active January 30, 2022 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imSmaity/86d795f5dd105138fb076c801e8af646 to your computer and use it in GitHub Desktop.
Save imSmaity/86d795f5dd105138fb076c801e8af646 to your computer and use it in GitHub Desktop.
This form created by JavaScript
const body=document.body
const label=document.createElement('label')
label.textContent="Name"
const input=document.createElement('input')
input.type='text'
input.id='name'
input.style.border='1px solid green'
input.style.padding='5px'
const label1=document.createElement('label')
label1.textContent="Phone"
const input1=document.createElement('input')
input1.type='number'
input1.id='number'
input1.style.border='1px solid green'
input1.style.padding='5px'
const label2=document.createElement('label')
label2.textContent="Email"
const input2=document.createElement('input')
input2.type='email'
input2.id='email'
input2.style.border='1px solid green'
input2.style.padding='5px'
const label3=document.createElement('label')
label3.textContent="Password"
const input3=document.createElement('input')
input3.type='password'
input3.id='password'
input3.style.border='1px solid green'
input3.style.padding='5px'
const button=document.createElement('button')
button.type='submit'
button.innerText='Submit'
button.id='btn'
const br=document.createElement('br')
const br1=document.createElement('br')
const br2=document.createElement('br')
const br3=document.createElement('br')
body.appendChild(label)
body.appendChild(input)
body.appendChild(br)
body.appendChild(label1)
body.appendChild(input1)
body.appendChild(br1)
body.appendChild(label2)
body.appendChild(input2)
body.appendChild(br2)
body.appendChild(label3)
body.appendChild(input3)
body.appendChild(br3)
body.appendChild(button)
var btn=document.querySelector('#btn')
btn.addEventListener('click',()=>{
alert(`Name: ${input.value} Number: ${input1.value} E-mail: ${input2.value} Password: ${input3.value}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment