|
Q920 How can I populate a form field if it is empty when the form is submitted?
irt.org | Knowledge Base | JavaScript | Form 6 | Q920 [ previous next ]
Q920 How can I populate a form field if it is empty when the form is submitted?
Try:
<script language="JavaScript"><!--
function defaultField(what,text) {
if (what.value == '')
what.value = text;
}
//--></script>
<form onSubmit="defaultField(this.form.tel,'No phone')">
<input type="text" name="tel">
</form>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.