Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Javascript to custom HTML
    text
    copied!<p>I really cant figure this out, and have spend much time searching for the answer, but nothing have worked..</p> <p>I have created a contant page in Joomla "Custom HMTL" module, using form and php, and i want to make a function that checks if the fields are correct and the typed emal is a valid email. If not i want a alert message to be showed.</p> <p>I have tryed using php and javascript. I think my javascript works fine, but dossent seem to work with the "Custom HTML" module for Joomla.</p> <p>Does any one know how to add Javascript? or is there an easier way to do this? Iam using JCE editor and Joomla 2.5</p> <pre><code> function validate_form(thisform) { var v1 = document.getElementsByName('name'); if (v1.value &lt; '!') { alert('Feltet navn skal udfyldes'); v1.focus(); return false; } var regex = new RegExp('^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$'); if (!regex.test(thisform.mail.value)) { alert("Email-adressen indeholder ugyldige tegn\r\nEller er på anden måde ikke korrekt udfyldt"); thisform.mail.focus(); return (false); } var v2 = document.getElementsByName('message'); if (v2.value &lt; '!') { alert('Feltet beskrivelse skal udfyldes'); v2.focus(); return false; } } &lt;/script&gt; &lt;form action="http://test.webkjaer.dk/templates/tilbud.php" method="post" enctype="multipart/form-data" onsubmit="return validate_form(this)"&gt; &lt;table style="width: 575px;" border="0" align="left"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;Navn &lt;span style="color: #ff0000;"&gt;*&lt;/span&gt; &lt;input type="text" name="name" /&gt; &lt;/td&gt; &lt;td&gt;E-mail &lt;span style="color: #ff0000;"&gt;*&lt;/span&gt; &lt;input type="text" name="email" / &gt; &lt;/td&gt; </code></pre> <p>...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload