joonstar
05-28-2005, 05:30 AM
<script type = 'text/javascript'>
function validate(f) {
if (f['title1'].value.length == 0) {
alert('Title1, please');
return false
}
if (f['message1'].value.length == 0) {
alert('Message1, please');
return false
}
if (f['password1'].value.length == 0) {
alert('password1, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title1' size='70'><br>
<textarea name='message1'
cols='70'
rows='10'></textarea><br>
<input name='password1' size='70'><br>
<input type='submit' value='submit'>
</form>
The above code has one form and it works fine in alert.
I like to make it work in 2 forms. so I made the following code.
<script type = 'text/javascript'>
function validate(f) {
if (f['title1'].value.length == 0) {
alert('Title1, please');
return false
}
if (f['message1'].value.length == 0) {
alert('Message1, please');
return false
}
if (f['password1'].value.length == 0) {
alert('password1, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title1' size='70'><br>
<textarea name='message1'
cols='70'
rows='10'></textarea><br>
<input name='password1' size='70'><br>
<input type='submit' value='submit'>
</form>
<script type = 'text/javascript'>
function validate(f) {
if (f['title2'].value.length == 0) {
alert('Title2, please');
return false
}
if (f['message2'].value.length == 0) {
alert('Message2, please');
return false
}
if (f['password2'].value.length == 0) {
alert('password2, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title2' size='70'><br>
<textarea name='message2'
cols='70'
rows='10'></textarea><br>
<input name='password2' size='70'><br>
<input type='submit' value='submit'>
</form>
The above trial code which has two javascripts and 2 forms doesn't work correctly.
The second form works fine in alerting but the first form doesn't work correctly in alerting?
How can I make it work both the first form and the second form in alerting?
function validate(f) {
if (f['title1'].value.length == 0) {
alert('Title1, please');
return false
}
if (f['message1'].value.length == 0) {
alert('Message1, please');
return false
}
if (f['password1'].value.length == 0) {
alert('password1, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title1' size='70'><br>
<textarea name='message1'
cols='70'
rows='10'></textarea><br>
<input name='password1' size='70'><br>
<input type='submit' value='submit'>
</form>
The above code has one form and it works fine in alert.
I like to make it work in 2 forms. so I made the following code.
<script type = 'text/javascript'>
function validate(f) {
if (f['title1'].value.length == 0) {
alert('Title1, please');
return false
}
if (f['message1'].value.length == 0) {
alert('Message1, please');
return false
}
if (f['password1'].value.length == 0) {
alert('password1, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title1' size='70'><br>
<textarea name='message1'
cols='70'
rows='10'></textarea><br>
<input name='password1' size='70'><br>
<input type='submit' value='submit'>
</form>
<script type = 'text/javascript'>
function validate(f) {
if (f['title2'].value.length == 0) {
alert('Title2, please');
return false
}
if (f['message2'].value.length == 0) {
alert('Message2, please');
return false
}
if (f['password2'].value.length == 0) {
alert('password2, please');
return false
}
return true
}
</script>
<form action='action.cfm' method='post' onsubmit='return validate(this)'>
<input name='title2' size='70'><br>
<textarea name='message2'
cols='70'
rows='10'></textarea><br>
<input name='password2' size='70'><br>
<input type='submit' value='submit'>
</form>
The above trial code which has two javascripts and 2 forms doesn't work correctly.
The second form works fine in alerting but the first form doesn't work correctly in alerting?
How can I make it work both the first form and the second form in alerting?