submit forgotpassword form on 'enter'

Author Message

paul bolger

Thursday 09 August 2007 7:14:49 pm

At present the forgot password form resets 'silently' - it just deletes the user's input, meaning that they are quite likely to think they have actually submitted the form - when the user presses their 'enter' key instead of the 'submit' button.

Does anyone know how to modify this so hitting enter will submit the form?

regards

Paul Bolger

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

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

eZ debug

Timing: Jan 31 2025 06:21:55
Script start
Timing: Jan 31 2025 06:21:55
Module start 'layout'
Timing: Jan 31 2025 06:21:55
Module start 'content'
Timing: Jan 31 2025 06:21:56
Module end 'content'
Timing: Jan 31 2025 06:21:56
Script end

Main resources:

Total runtime1.2056 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.2500151.2266
Module start 'layout' 0.00620.0031 739.476636.6641
Module start 'content' 0.00931.1948 776.1406940.3516
Module end 'content' 1.20410.0014 1,716.492211.8438
Script end 1.2055  1,728.3359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2663160.0002
Check MTime0.00120.0995160.0001
Mysql Total
Database connection0.00110.090710.0011
Mysqli_queries1.140794.6207570.0200
Looping result0.00080.0657550.0000
Template Total1.163596.520.5818
Template load0.00230.190620.0011
Template processing1.161296.321620.5806
Template load and register function0.00150.125610.0015
states
state_id_array0.00200.165010.0020
state_identifier_array0.00200.166520.0010
Override
Cache load0.00190.1599190.0001
Sytem overhead
Fetch class attribute can translate value0.00100.081920.0005
Fetch class attribute name0.00220.186450.0004
XML
Image XML parsing0.00450.370320.0022
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00430.3605220.0002
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs