PDA

View Full Version : TextField problem


dannygallo
10-18-2002, 01:36 PM
Hi everyone, does anyone know how to automatically fill in a textfield box when the user submits a form if the textfield was left blank?

What i need to do is this...


I have a blank textfield that the user must fill in a 7 digit code. If the user decides to leave it blank; then on "submit" it will automatically fill in the blank textfield with an alternative code.

If the user fills in the textfield then it acts as a normal form.

Does this make sense?

Can anyone help?

Thanks for any help guys

Danny

beetle
10-18-2002, 03:11 PM
<form>
<input type="text" name="code">
<input type="submit" value="Submit" onClick="if (/^\s*$/.test(this.form.code.value)) this.form.code.value='ABC1234';return true;">
</form>