RWD Contact Us Active Element
-
29-09-2020 - |
Question
The contact us page in the RWD theme has the "name" box as the active element when you land on the page so the cursor is in this box and it is highlighted. This is a nuisance on a mobile device because you are hit with a keyboard in your face whenever you go to this page. How can I disable the "name" box being active?
Solution
Change below code:
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
to:
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', false);
//]]>
</script>
Check this file js/varien/form.js
initialize: function(formId, firstFieldFocus){
this.form = $(formId);
if (!this.form) {
return;
}
this.cache = $A();
this.currLoader = false;
this.currDataIndex = false;
this.validator = new Validation(this.form);
this.elementFocus = this.elementOnFocus.bindAsEventListener(this);
this.elementBlur = this.elementOnBlur.bindAsEventListener(this);
this.childLoader = this.onChangeChildLoad.bindAsEventListener(this);
this.highlightClass = 'highlight';
this.extraChildParams = '';
this.firstFieldFocus= firstFieldFocus || false;
this.bindElements();
if(this.firstFieldFocus){
try{
Form.Element.focus(Form.findFirstElement(this.form))
}
catch(e){}
}
}
If you set firstFieldFocus to false it will not trigger focus on first field.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange