I know this has to be something obvious, but even after following instructions elsewhere, I'm getting the same result.
The alert on the JavaScript call comes up, but after clicking okay, it continues to submit the form.
function validateBadEmail(inputText)
{
var mailformat = /.ru$/
if(inputText.value.match(mailformat))
{
alert("This is not an accepted email address");
inputText.preventDefault();
}
}
Here is how I'm calling it:
<input type="button" id="submit-btn" class="btn btn-blue btn-less-padding" name="submit-btn" value="<?= $txt_submit_btn; ?>" tabindex="0" onclick="return validateBadEmail(document.the_form.email)"/>
I have tried this by using return false
instead of preventDefault
but that's having the same effect.
If I change the onclick
to onsubmit
it doesn't even call the javascript at all.
Edit: clearly preventDefault is the wrong way, but if I try to do it this way, I'm still getting the same results
function validateBadEmail(inputText)
{
var mailformat = /.ru$/
if(inputText.value.match(mailformat))
{
alert("This is not an accepted email address");
return false;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…