in my website ther is a textbox for entering year.. i have given code for displaying an alert message if the textbox is left empty.. 1. function validate() { 2. if(document.form.year.value=="") 3. { 4. alert ('Please enter year'); 5. return false; 6. }} PHP: it is working , but i want to do is.. it should display an alert message if the length of the numbers is less than 4 or greater than 4 how can i do that?? please give me a solution... thanks......
Hi, this function should solve it for you. Cheers, Rich.. function validate() { if(document.form.year.value=="") { alert ('Please enter year'); return false; } else if(document.form.year.value.length > 4) { alert ('The year must be in the format "YYYY"'); return false; } else if(document.form.year.value.length < 4) { alert ('The year must be in the format "YYYY"'); return false; } }