Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    Lebanon
    Posts
    223
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Validation redirection error

    I'm facing a validation error, whenever I leave any of the fields blank, it gives me a warning and then it redirects me to (index.php?option=com_ccnewsletter&view=ccnewsletter)

    What I wanna know is how can I freeze the page until all fields are filled?

    This is the javascript code:
    Code:
    	<script type="text/javascript">
    	function formsubmit(task)
    	{
    		var form = document.subscribeFormModule;
    		if(task == "addSubscriber")
    		{
    			if(form.name.value== "")
    			{
    				alert('<?php echo $parameters['namewarning']; ?>');
    			}
    			else if(form.email.value == "")
    			{
    				alert('<?php echo $parameters['emailwarning']; ?>');
    			}
    			else if(( form.email.value.search("@") == -1) || ( form.email.value.search("[.*]" ) == -1 ))
    			{
    				alert('<?php echo $parameters['emailwarning']; ?>');
    			}
    
    			<?php if($parameters['showterm'])
    			{
    			?>
    			else if(form.terms_condition_ch.checked == false)
    			{
    				alert ('<?php echo $parameters['terms_cond_warn']; ?>');
    
    			}
    			<?php
    			}
    			?>
    
    			else
    			{
    				form.task.value = "addSubscriber";
    				form.submit();
    			}
    		}
    		else if(task == "removeSubscriberByEmail")
    		{
    			if(form.email.value == "")
    			{
    				alert('<?php echo $parameters['emailwarning']; ?>');
    			}
    			else if(( form.email.value.search("@") == -1) || ( form.email.value.search("[.*]" ) == -1 ))
    			{
    				alert('<?php echo $parameters['emailwarning']; ?>');
    			}
    			else
    			{
    				form.task.value = "removeSubscriberByEmail";
    				form.submit();
    			}
    		}
    	}
    	</script>
    And this is the form's code:
    Code:
    <div class="mainnewsletter">
    		<p><?php echo $parameters['introduction'] ?></p>
            <div class="module" style="padding-top: 0px;">
    		<div class="normalsublayout">
    		<form class="form-login" action="<?php echo JRoute::_('index.php?option=com_ccnewsletter&amp;view=ccnewsletter');?>" method="post" name="subscribeFormModule" id="subscribeFormModule">
    			<p><div>
    			<?php echo $parameters['name']; ?>:
                <div class="username-block">
                <div class="input-field-l">
                <input class="inputbox" type="text" onblur="if(this.value=='') this.value='YourName';" onfocus="if(this.value=='YourName') this.value='';" name="name" id="name" value="<?php echo $name; ?>" />
    			</div></div>
    			</div>
    			</p>
    			<p>
    			<div>
    			<?php echo $parameters['email']; ?>:
                <div class="password-block">
    			<div class="input-field-l">
                <input class="inputbox" type="text" onblur="if(this.value=='') this.value='youremail@domain.com';" onfocus="if(this.value=='youremail@domain.com') this.value='';" name="email" id="email" size="15" maxlength="35" value="<?php echo $email; ?>" />
    			</div>
    			</div>
    			</div>
    			</p>
    			<?php if($parameters['showterm'])
    			{
    			?>
    			<p>
    			<input id="ccnewsletter" name="terms_condition_ch" class="inputbox" type="checkbox">
    			<a style="font-size:14px;color:#4E4E51; display: margin:0px 0px 0px 5px;text-decoration:none;" href='<?php echo $cid; ?>' class="modal" rel="{handler: 'iframe', size: {x: 700, y: 375}}"><?php echo $terms;?></a>
    			</p>
    			<?php
    			}
    			if($unsubscribe)
    			{
    			?>
    			<p>
    				<input class="button" type="submit" id="addSubscriber" name="addSubscriber" value="<?php echo $parameters['subscribe']; ?>"  onclick="formsubmit('addSubscriber');"/>
              </p>
    				<p><input class="button" type="submit" id="removeSubscriberByEmail" name="removeSubscriberByEmail" value="<?php echo $parameters['unsubscribe']; ?>"  onclick="formsubmit('removeSubscriberByEmail');"/>
    			</p>
    			<?php
    			}
    			else
    			{
    			?><div class="readon-wrap1">
    <div class="readon1-l"></div>
    <span class="readon-main"><span class="readon1-m"><span class="readon1-r"><input class="button" type="submit" id="addSubscriber" name="addSubscriber" value="<?php echo $parameters['subscribe']; ?>"  onclick="formsubmit('addSubscriber');"/></span></span></span></div>
    				
    				<!--<p><center><input  type="image" src="images/back_f2.png" id="addSubscriber" name="addSubscriber" value="<?php echo $parameters['subscribe']; ?>"  onclick="formsubmit('addSubscriber');"/></center></p>-->
    			<?php
    			}
    			?>
    			<input type="hidden" name="option" value="com_ccnewsletter" />
    			<!--<input type="hidden" name="task" value="addSubscriber" />-->
    			<input type="hidden" name="task" value="" />
    			</form>
    		</div>
    	</div></div>
    I don't know, maybe I'm missing something because it was working fine a before.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Please post a link to your page or the parsed output taken from browser's "view source" option.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    Lebanon
    Posts
    223
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Unfortunately I'm working on localhost, so here's the "view source" code.
    It's a bit long because I'm using joomla.

    The code of the newsletter starts from
    Code:
    <div class="module-header"><div class="module-header2"><div class="module-header3"><h3 class="module-title">Newsletter </h3></div></div></div>
    Thanks for your help.
    Attached Files Attached Files

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Um... there might be some error in your javascript. I'd recommend you to change the type of your button elements to type="button" and then use firebug to get the errors from its console.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Snitz (12-30-2009)

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Location
    Lebanon
    Posts
    223
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I'd recommend you to change the type of your button elements to type="button"
    That worked, thanks mate.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by Snitz View Post
    That worked, thanks mate.
    Forgot to mention.. after fixing the error, you should revert the type to submit, otherwise your form won't work for those who have no javascript support.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •