|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help... Simple question:
I have a form that gets submited to my send mail program but i want to make some fields requred and if they are not filled out then it will not let them submit the form help please Chris larson@cache.net |
|
#2
|
|||
|
|||
|
function checkFields() {
em = "The following field(s) cannot be blank: " if (document.form.field1.value == "") em = em + "n * Text1"; if (document.form.field2.value == "") em = em + "n * Text2"; if (em.indexOf('*') > 0) { alert(em); return false; } } Also, you want to make sure that code is inside SCRIPT tags and that you replace form with the name of your form, the field tags with the names of the fields, and Text with the actual Text you want displayed. Then, just add/remove lines to accomodate the number of fields for which you want the alert to show. |
|
#3
|
|||
|
|||
|
<HEAD>
<script> function validateForm(form) { if (!form.name.value) { alert("Fill it"); form.name.focus(); return false; } } </HEAD> <BODY> <form action="filenm" method="post" onSubmit="return validateForm(this)"> <input type=text name="name"> <input type="submit"> </form> </BODY> </script> ------------------ CyberOsc sphmjf_oscario@gurlmail.com ** It's the world of Oscario ** |
|
#4
|
|||
|
|||
|
sorry,
a little mistake in my code above. it should be : <HEAD> <SCRIPT> function validateForm(form) { etc. } </SCRIPT> </HEAD> <BODY> etc </BODY> ------------------ CyberOsc sphmjf_oscario@gurlmail.com ** It's the world of Oscario ** |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > HTML Forms |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|