Hi,
CMSmadesimple: 1.5.2
FEU: 1.6.4
SelfRegistration: 1.2.3
In order to implement a javascript check on email based on domain name, I added a "onsubmit" to the default form in the template of the selfregistration module.
I've replaced {$startform} with
and {$endform}
with .
My CheckMail() is:
Without entering anything or a bogus email, the javascript alert is displayed as expected.
If I enter a valid email, the form is submitted and nothing happens, that is I can see
the form being submitted, but the email confirmation message is not displayed, and
no user is created in the selfregistration module.
If I put back {$startform} and {$endform}, it works again, but then I can't add an onsubmit action.
Is there any other way to do a custom check on email?
Thanks,
Jim
[solved] selfregistration & onsubmit with custom javascript
-
- Forum Members
- Posts: 10
- Joined: Tue Mar 31, 2009 3:33 pm
[solved] selfregistration & onsubmit with custom javascript
Last edited by cerebus180 on Wed Jul 15, 2009 3:41 pm, edited 1 time in total.
Re: selfregistration & onsubmit with custom javascript
The reason it isn't working is there are 2-3 lines that you are missing in the $startform. As a general rule I prefer to use the "replace" command to modify smarty variable instead of leaving them out and putting in my own lines.
If you want to stick with using onsubmit try:
otherwise try adding the check in a onblur from the email field or a onclick for the submit button.
If you want to stick with using onsubmit try:
Code: Select all
{$startform|replace:'action':'onsubmit="checkMail()" action'}
-
- Forum Members
- Posts: 10
- Joined: Tue Mar 31, 2009 3:33 pm
Re: selfregistration & onsubmit with custom javascript
Works like a charm, much thanks! 

-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: [solved] selfregistration & onsubmit with custom javascript
Just use jQuery... makes things much easier. You don't have to do any funky things like replace, or changing the form tag
I suggest just wrapping the form template in a div with some id, and then just using jQuery selectors to isolate the appropriate fields.
Below is an example of the JQuery code I added to the FEU login template to ask a confirm message if the submit button was pressed.
Given this little bit of code as a starting point, you should easily be able to do whatever javascript you want without modifying the original template or using any funky smarty modifiers on form elements.
I suggest just wrapping the form template in a div with some id, and then just using jQuery selectors to isolate the appropriate fields.
Below is an example of the JQuery code I added to the FEU login template to ask a confirm message if the submit button was pressed.
Given this little bit of code as a starting point, you should easily be able to do whatever javascript you want without modifying the original template or using any funky smarty modifiers on form elements.
Code: Select all
{literal}
<__script__ type="text/javascript">
jQuery(document).ready(function(){
jQuery('#loginform :submit').click(function(){
// some type of submit button was pressed
if( jQuery(this).attr('name').match(/submit$/) )
{
// it was the submit button, not any other button
var tmp = confirm('Do you really want to login?');
if( !$tmp ) return false;
}
});
});
</__script>
{/literal}
<div id='loginform'>
{* the rest of the FEU loginform template *}
</div>
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.