Skip to content

Instantly share code, notes, and snippets.

@jimmiw
Created February 9, 2010 09:50
Show Gist options
  • Save jimmiw/299058 to your computer and use it in GitHub Desktop.
Save jimmiw/299058 to your computer and use it in GitHub Desktop.
Event.observe('submit_button','click', function(e) {
e.stop();
var contact = $('form_name').getValue();
var comment = $('form_comment').getValue();
if(contact != '') {
var phoneRegExp = new RegExp('^[+]{0,1}[0-9]+$');
var emailRegExp = new RegExp('^[a-zA-Z0-9._+-]+[@]{1}[a-zA-Z0-9._-]+[.]{1}[a-zA-Z0-9]+$');
if(phoneRegExp.test(contact) || emailRegExp.test(contact)) {
$('contact_form').submit();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment