I need to throw an alert conditionally, but it's throwing every time.
This is my first attempt at jQuery, and I'm excited to finally be playing with it.
(Every year I promise myself I'll get more familiar with JS, and I have yet to follow through ... so I'm trying to do something about it :-)
I'm throwing together a page where
contenteditable=true if a validated key gets passed.
Here's the basics of my simple PHP:
PHP Code:
if(!empty($_GET['editkey'])){
$secretOfTime = $_GET['editkey'];
if($secretOfTime == md5(round($timestamp, -1)) || $secretOfTime == md5(round(($timestamp-3), -1))){
//match
$editable = 'contenteditable="true"';
$notValidated = '';
}else{
//no match
$editable = '';
$notValidated = '<span id="editModeFailedToValidate"></span>';
}
}
And here's my JS:
Code:
<script type="text/javascript">
$(document.getElementById('editModeFailedToValidate')).ready(function() {
alert('The Edit-Key did not match, Please try again.');
});
</script>
It throws the alert regardless of whether the
'editModeFailedToValidate' ID is found.
I even tested with
getElementById('someNonsenseTestValue'), and it still gave the alert.
Am I going about this
all wrong, or do I just need some little tweaks?
~ Mo