Jump to content

Cum Fac Un Camp Dintr-Un Formular Obligatoriu?


Stefan

Recommended Posts

Cum fac ca numele, email-ul, subiectul si mesajul sa fie obligatorii ?

Am urmatorul cod :

<form method="post" action="contact.php" border="0">
							<fieldset><legend class="texte_legende">your informations</legend>
								<table cellpadding=5 cellspacing=0 border="0">
								<tr>
									<td class="texte">Full name :</td>
									<td><input class="champ" type="text" name="name" id="name"></td>
								</tr>
								<tr>
									<td class="texte">Email Address :</td>
									<td><input class="champ" type="text" name="email"  id="email" ></td>
								</tr>
								<tr>
									<td class="texte">Telephone :</td>
									<td><input class="champ" type="text" name="telephone"  id="email" ></td>
								</tr>
								</table>
							</fieldset>
							<br>
							
							<fieldset><legend class="texte_legende">your message</legend>
								<table cellpadding=5 cellspacing=0 border="0">
								<tr>
									<td class="texte">Subject :</td>
									<td><input class="champ" type="text" name="subject" id="subject"></td>
								</tr>
								<tr>
									<td class="texte" valign="top"s>Message :</td>
									<td height="52" valign="bottom"><textarea class="champ" name="message" id="message"></textarea></td>
								</tr>
								</table>
							</fieldset>
							
							<table width="380" border="0" cellpadding=0 cellspacing=0>
							<tr>
								<td colspan="2" align="center"><input class="button_send" type="submit" value="Send"></td>
							</tr>
							</table>
						</form>
					</div>
					<div class="clear"></div>
				</div>
			</div>
Link to comment
Share on other sites

  • Moderators

Metoda simpla ar fi sa pui:

required

La fiecare input. Un exemplu:

<input class="champ" type="text" name="name" id="name" required>

Va functiona pe majoritatea browserelor, doar Safari va trece peste.

 

Alta metoda ar fi cu Javascript, sa verifici value de la fiecare input, un exemplu: 

Javascript validation for empty input field

  • Upvote 1

PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.