Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <section class="wrapper-form">
    <form id="form">
        <legend>Número Quadrado Perfeito</legend>

        <div class="input-group">
          <label for="num">Digite o número:</label>
          <input id="num" type="number"/>
          <input id="button" type="submit" value="Verificar">



                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

:root {
  /* 62.5% de 16px(padrão do navegador) = 10px */
  font-size: 62.5%;

  font: 400 1.8rem/1 'sans-serif';

.wrapper-form {
  width: 100%;
  height: 100vh;

fieldset {
  width: 100%;
  max-width: 50rem;
  min-height: 20rem;
  padding: 1.5rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #FFFDE7;
  border: 0;
  box-shadow: 1rem 1rem 1rem #ccc, -1rem 1rem 1rem #ccc;

fieldset legend {
  font-size: 3rem;

.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

.input-group input {
  width: 80%;
  margin-top: 1.5rem;
  padding: 0.6rem;
  border: 0;
  box-shadow: 0 0 0.2rem #aaa;
  color: #444;

.input-group label {
  align-self: start;

.input-group  input[type="submit"]{
  cursor: pointer;
  width: 50%;



                function calcularQuadradoPerfeito (num) {
  //retira a raiz quadrada, valor inteiro
  const raizQ = parseInt(Math.sqrt(num));
  //verifica se a raiz quadrada elevado ao quadrado é um valor exato
  return (raizQ * raizQ) == num;

function validaEntrada (num) {
  if(num == "" || num <= 0){
    return false;
  return true;

const botao = document.getElementById('button');

const form = document.getElementById('form');

form.addEventListener('submit', function(event) {
  const value = document.getElementById("num").value;

    alert('Insirar algum número maior que zero');
  }else if(calcularQuadradoPerfeito (value)){
    alert('É Quadrado perfeito');
    alert('Não é quadrado perfeito');