R.K.Bhardwaj
R.K.Bhardwaj

Reputation: 2192

javascript error newsletter not working in responsive view

Goodmorning to all

I am facing a little problem, with my big commerce store. Here is store URL http://rp-working-environment6.mybigcommerce.com/ The problem is that the newsletter script working on desktop view fine please check the screenshot . http://prntscr.com/eft5ea but if I did the same process in responsive view its giving error please check the screenshot http://prntscr.com/eft64a

There is a javascript for the newsletter which is working on the desktop but not responsive view . also if I enable mobile template from backend then newsletter working fine in both view desktop and mobile, but I don't want to enable mobile template. so please help to make working it in responsive view. here is script code:--

<script type="text/javascript">

  $('#subscribe_form').submit(function() {
  if($('#nl_first_name').val() == '') {
  alert('%%LNG_NewsletterEnterFirstName%%');
  $('#nl_first_name').focus();
  return false;
  }

  if($('#nl_email').val() == '') {
  alert('%%LNG_NewsletterEnterEmail%%');
  $('#nl_email').focus();
  return false;
  }

  if($('#nl_email').val().indexOf('@') == -1 || $('#nl_email').val().indexOf('.') == -1) {
  alert('%%LNG_NewsletterEnterValidEmail%%');
  $('#nl_email').focus();
  $('#nl_email').select();
  return false;
  }

  // Set the action of the form to stop spammers
  $('#subscribe_form').append("<input type=\"hidden\" name=\"check\" value=\"1\" \/>");
  return true;

  });

  </script>

Upvotes: 1

Views: 71

Answers (1)

R.K.Bhardwaj
R.K.Bhardwaj

Reputation: 2192

I have solved my issue I have to duplicate the form of newsletters and change the whole script to the 2nd newsletter.

<script type="text/javascript">

  $('#subscribe_form2').submit(function() {
  if($('#nl_first_name').val() == '') {
  alert('%%LNG_NewsletterEnterFirstName%%');
  $('#nl_first_name').focus();
  return false;
  }

  if($('#nl_email').val() == '') {
  alert('%%LNG_NewsletterEnterEmail%%');
  $('#nl_email').focus();
  return false;
  }

  if($('#nl_email').val().indexOf('@') == -1 || $('#nl_email').val().indexOf('.') == -1) {
  alert('%%LNG_NewsletterEnterValidEmail%%');
  $('#nl_email').focus();
  $('#nl_email').select();
  return false;
  }

  // Set the action of the form to stop spammers
  $('#subscribe_form2').append("<input type=\"hidden\" name=\"check\" value=\"1\" \/>");
  return true;

  });

  </script>

Upvotes: 1

Related Questions