I normally program in php, but I need to check the value of a text box in javascript. I have the following code... // JavaScript Document function isZip(item) { var item=item; alert(document.frmClaim.item.value);//to verify it has gotten the value var str=document.frmClaim.item.value; alert("yes"); if(isNaN(str)){ alert('That value must be a number.'); document.frmClaim.item.focus(); document.frmClaim.item.value = ''; }; } ><input type="text" onblur="isZip('insured_zip')" size="7" maxlength="9" name="insured_zip" id="insured_zip" value="<?php echo $_POST['insured_zip']; ?>"> Code (markup):
it doesn't alert the yes or the value. I can alert item and it alerts insured_zip. Anyone have any ideas? Thanks!
and if I replace "item" with insured_zip it works. So basically I need help getting it to use insured_zip as the item.
Ok, I got it to check the value, but now I need it to set the focus back to the object if its not a number. I've tried 50 different things with that focus(). Any ideas?