Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Where am i going wrong? Simple Function ?! Re: Where am i going wrong? Simple Function ?!

#103116
JohnMotylJr
Participant

Making more progress, i think i figured it out. Is this good practice?

/* Updated, still needs work. Im still learning */
var _inputArray = $([ "#name", "#email", "#subject", "#message" ]);
var _regexEmail = /^([0-9a-zA-Z]([.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$/;
var _validate = function ($e)
{
$e.preventDefault();

if ($( _inputArray[1] ).val().match( _regexEmail )) return $(document.body).append("It is True");
else return $(document.body).append("It is False");

};


$(document).ready(function()
{
$('#button').click(_validate);
});

Any suggestions?