submit forgotpassword form on 'enter'

submit forgotpassword form on 'enter'

Thursday 09 August 2007 7:14:49 pm - 2 replies

Author Message

Pascal Specht

Friday 10 August 2007 12:12:18 am

Hi Paul,

I did something similar with javascript. Sice I don't like to break the logics of a website if the user agent disabled javascript, there's a lot of code pollution to make things work if javascript is not enabled, but that's the price to pay:

I hope you can reuse some of the code below and adapt it to your needs, for example by using onkeydown() event handler and trigger a submitform(true) somehow:

the trick is to use display:none to hide javascript buttons if javascript is not enabled. It will only be changed on the fly to visible by javascript.

Happy coding,
-Pascal

<div id="javabuttons" class="buttonblock" style="display:none;">  	
<input type="hidden" id="jsfakebutton" name="jsfakebutton" value="dynamic"> 

<a href="javascript:submitform(true);" 
{*
  onMouseOver="window.status=''; return true"
  onMouseOut="window.status='';return true"
  onKeyDown="submitform(true);"  
*}
  id="jssubmitbutton" class="btn site"> {'Login'|i18n('bg_user/user/login')}</a>
</div>


<noscript>
<div class="buttonblock">
<input class="defaultbutton" type="submit" name="LoginButton" value="{'Login'|i18n('bg_user/user/login')}" tabindex="1" />
</div>
</noscript>


{run-once}
{literal}
	<script language='javascript' type='text/javascript'>
	function submitform( ok )
	{
	  var obj = document.getElementById("jsfakebutton");
	  if ( ok )
	  {
		obj.name="LoginButton";
		{/literal}
		obj.value="{'Login'|i18n('bg_user/user/login')}";
		{literal}
	  }
	  else
	  {
		obj.name="CancelButton"; 
		{/literal}
		obj.value="{'Discard'|i18n('bg_user/user/register')}";
		{literal}
	  }
	  document.loginform.submit();
	}

	var existingOnload = null;
	if (window.onload) { existingOnload = window.onload; }

	window.onload = function (ev) {
		if (existingOnload) { existingOnload(ev); }
        showjavascriptbuttons();
	}
	

	function showjavascriptbuttons() {
		document.getElementById( 'javabuttons' ).style.display = "block";
	}
    
   </script>
{/literal}
{/run-once}

paul bolger

Friday 10 August 2007 12:27:48 am

Thanks Pascal, I'll give it a try over the weekend and let you know how it goes.

Paul Bolger

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.