juse have a quick question, i have try to do the validation for email address. i need to do a validation such as validate if an email address is a school email(which means end with edu), but i decide to start from validate the normal email, the code below is what i have down.
Javascript part
function ok_Email(email){ var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(filter.test(email)){ return true; window.alert('This is an email') } else{ return false; window.alert('This is not an email') } } Html part
<form name="myform" onSubmit="return ok_Email(this);"> <p> Please enter your email address: <br> <input type="text" size=40 name="user_email"> <p> <input type = submit value="Send"> </form> The problem for this code is when i click the send buttom, the page did not change. As you see in the code, it should have an alert comes out but it doesn't. I think the problem comes from the buttom part but i am not sure.......
returnstatement doesn't mean "when it's time to return, please make the value such-and-such." It means, "return right now with this value and forget about the rest of the function."