title: How can I separate button operation in javascript and Django?
body: <p>I made sign up form page using Django. When I fill in the register form, data is included in database. But, when I click the email check button, register button also is clicked and the page is reloaded. How can I separate these two button?</p>
  <pre class="lang-js prettyprint-override"><code>$('.email-check-btn').click(function (){
      const email = $('#email').val()
      if (email === ''){
          alert('please check the form')
      }
  
      $.ajax({
          type: 'GET',
          url: 'email-check?email=' + email,
          datatype: 'json',
          success: function (response){
              if (response.result !== 'success') {
                  alert(response.data)
                  return
              }
              if (response.data === 'exist') {
                  alert('that email is already exist!')
                  $('#email').val('').focus()
              } else {
                  alert('good, you can use it!!')
              }
          }
      })
  })
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>def email_check(request):
      try:
          user = get_user_model().objects.get(email=request.GET['email'])
      except Exception as e:
          user = None
  
      result = {
          'result': 'success',
          'data': 'not exist' if user is None else 'exist'
      }
      return JsonResponse(result)
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>def sign_up(request):
      if request.method == 'GET':
          user = request.user.is_authenticated
          if user:
              return redirect('/main')
          else:
              return render(request, 'sign_in_and_up.html')
  
      elif request.method == 'POST':
          user_id = request.POST.get('username', '')
          password = request.POST.get('password', '')
          password2 = request.POST.get('password2', '')
          nickname = request.POST.get('nickname', '')
          email = request.POST.get('email', '')
  
          if password != password2:
              return render(request, 'sign_in_and_up.html', {'error': 'check your password'})
          else:
              if user_id == '' or password == '' or nickname == '' or email == '':
                  return render(request, 'sign_in_and_up.html', {'error': 'fill in all the blank'})
  
              exist_user = get_user_model().objects.filter(username=user_id)
              if exist_user:
                  return render(request, 'sign_in_and_up.html', {'error': 'already exist'})
              else:
                  UserModel.objects.create_user(username=user_id, password=password, nickname=nickname, email=email)
                  return render(request, 'sign_in_and_up.html')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/K4Vg8.png" rel="nofollow noreferrer">error code</a></p>