You are here: irt.org | FAQ | JavaScript | Form | 5 | Q292 [ previous next ]
<SCRIPT LANGUAGE="JavaScript"><!-- function validate() { if (document.myform.mytext.value.indexOf('@') > -1) return true; // simple check for @ within the form field else { // prompt for alternative value document.myform.mytext.value = prompt('include a @ dummy',document.myform.mytext.value); setTimeout('document.myform.mybutton.click()',100); return false; } } //--></SCRIPT> <FORM NAME="myform" onSubmit="return validate()"> <INPUT TYPE="TEXT" NAME="mytext"> <INPUT TYPE="SUBMIT" NAME="mybutton"> </FORM>