![Photo](http://forum.wmonline.com.br/uploads/profile/photo-thumb-29812.jpg?_r=0)
Arroba (@) Obrigatória No Formulário. Como Fazer ?
#1
Posted 16/07/2006, 12:06
Alguém pode me dizer como faço pra num campo de formulário ser obrigatório o uso da "@" (arroba), retornando um erro em javascript caso não seja usada ?
Obrigado.
#2
Posted 16/07/2006, 12:39
function validaFormContato(){
//nome do Form de envio
d = document.contato;
//validar nome
if (d.Nome.value == ""){
alert("O campo " + d.Nome.name + " deve ser preenchido!");
d.Nome.focus();
return false;
}
//validar telefone
if (d.Telefone.value == ""){
alert ("O campo " + d.Telefone.name + " deve ser preenchido!");
d.Telefone.focus();
return false;
}
//validar email
if (d.Email.value == ""){
alert("O campo " + d.Email.name + " deve ser preenchido!");
d.Email.focus();
return false;
}
//validar email(verificao de endereco eletrônico)
parte1 = d.Email.value.indexOf("@");
parte2 = d.Email.value.indexOf(".");
parte3 = d.Email.value.length;
if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
alert ("O campo " + d.Email.name + " deve conter um endereco eletronico! Ex: seunome@seuprovedor.com.br");
d.Email.focus();
return false;
}
//validar assunto
if (d.Assunto.value == ""){
alert("O campo " + d.Assunto.name + " deve ser preenchido!");
d.Assunto.focus();
return false;
}
//validar Mensagem
if (d.Mensagem.value == ""){
alert("O campo " + d.Mensagem.name + " deve ser preenchido!");
d.Mensagem.focus();
return false;
}
return true;
}
Com scrit acima crie um arquivo .js e depois faz a chamada na sua pagina, assim:
<script type="text/javascript" language="javascript" src="validaform.js"></script>
ai vc chama no no seu form assim:
<form action="pagina.html" method="POST" name="contato" onSubmit="return validaFormContato()">
falow t+
#3
Posted 16/07/2006, 13:26
Thiago, seu script é perfeito e funcional, porém, acho que para esse caso de somente validar um campo de email deve ser feito de uma forma menos complexa.
![(y)](http://forum.wmonline.com.br/public/style_emoticons/default/thumbs_up.gif)
<script>
function validaemail() {
if (document.getElementById('email').value == ""){
alert("O campo de e-mail deve ser preenchido.");
document.getElementById('email').focus();
return false;
}
else {
arroba = document.getElementById('email').value.indexOf("@");
ponto = document.getElementById('email').value.indexOf(".");
tamanho = document.getElementById('email').value.length;
if (!(arroba >= 2 && ponto >= 3 && tamanho >= 9)) {
alert ("Digite um e-mail válido.\n Exemplo: seunome@seuprovedor.com.br");
document.getElementById('email').focus();
return false;
}
else {
return true;
}
}
}
</script>
<form name="vai" action="pagina.extensão" onsubmit="return validaemail();">
<input type="text" size="20" id="email" />
<input type="submit" value="Validar">
</form>
Entende?
Sem querer ofender, OK? Somente ajudando.
![(y)](http://forum.wmonline.com.br/public/style_emoticons/default/thumbs_up.gif)
Bom, agradeço sua atenção e compreensão.
![(y)](http://forum.wmonline.com.br/public/style_emoticons/default/thumbs_up.gif)
Até mais, pessoas.
Fui.
![^_^](http://forum.wmonline.com.br/public/style_emoticons/default/happy.gif)
Edição feita por: invasoesdemaniacos, 16/07/2006, 13:29.
Localidade: Campinas - SP
Linguagem de desenvolvimento: XHTML | CSS (Tableless) | JavaScript | AJAX | PHP
Contatos: brkamikasecps@gmail.com | brkamikasecps@hotmail.com
#4
Posted 16/07/2006, 14:47
sua validação está legal mas, ela barra um e-mail válido do tipo:
a.silva@uol.com.br
Que tal tentar com expressões regulares?
![:D](http://forum.wmonline.com.br/public/style_emoticons/default/biggrin.gif)
#5
Posted 16/07/2006, 16:04
Verdade...
Desafio lançado, não?
Ok, segue mais enxuto ainda:
![^_^](http://forum.wmonline.com.br/public/style_emoticons/default/happy.gif)
<script> function validaemail() { var email = document.getElementById('email'); if (email.value == ""){ alert("O campo de e-mail deve ser preenchido."); email.focus(); return false; } else { var valor = email.value; padrao = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; OK = padrao.exec(valor); if (!OK) { alert ("Digite um e-mail válido.\n Exemplo: seunome@seuprovedor.com.br"); document.getElementById('email').focus(); return false; } else { return true; } } } </script> <form name="vai" action="pagina.extensão" onsubmit="return validaemail();"> <input type="text" size="20" id="email" /> <input type="submit" value="Validar"> </form>
![^_^](http://forum.wmonline.com.br/public/style_emoticons/default/happy.gif)
Falow. Valeu Klaus.
![(y)](http://forum.wmonline.com.br/public/style_emoticons/default/thumbs_up.gif)
Bem complicadinho ER.
![^_^](http://forum.wmonline.com.br/public/style_emoticons/default/happy.gif)
Fui.
![^_^](http://forum.wmonline.com.br/public/style_emoticons/default/happy.gif)
Localidade: Campinas - SP
Linguagem de desenvolvimento: XHTML | CSS (Tableless) | JavaScript | AJAX | PHP
Contatos: brkamikasecps@gmail.com | brkamikasecps@hotmail.com
#6
Posted 26/09/2017, 13:18
Mavidol cialis Meilleur Site Pour Commander Cialis Which Is Stronger Cipro And Amoxicillin
Acheter Du Cialis 10mg Effetti Collaterali Viagra Generico cialis Cialis Uso Prolungato Cialis Eintritt Wirkung
#7
Posted 08/10/2017, 18:45
Osu Levitra In Farmacia viagra Lasix No Prescription Needed Pfizer Viagra Prezzo
#8
Posted 23/10/2017, 08:37
Propecia Cost Per Month Amoxicillin One Day Over Expire Date Cialis Online Fast Delivery cheap levitra canada Avelox And Zithromax Cytotec A Bas Prix Amoxicillin Mouth Dissolve
Cialis Soft Tabs Online Prezzo Levitra Drug Cost In Canada viagra Best Buy On Cialus
#9
Posted 23/10/2017, 22:23
#10
Posted 24/10/2017, 13:24
![progect11.jpg](http://projectgold.ru/img/progect11.jpg)
![buy.png](http://projectgold.ru/buy.png)
![47.jpg](http://projectgold.ru/img/adaliimg_e/47.jpg)
Discounts! new beauty 2017
![progect11.jpg](http://projectgold.ru/img/progect11.jpg)
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).
![buy.png](http://projectgold.ru/buy.png)
READ MORE
5PcsBag Plastic Fishing Rod Pole Hook Keeper for Lures Bait Spoon Treble Fish Hook Safety Holder Fishing Tackle Accessories ( 1.86 $)
Mini Pool Set Billiard Ball Table Game Children Toy-32.63 $
makeup sponge blender beauty original cosmetic puff powder puff retail packing Fast Shipping ( 12.36 $)
7PCS Russian Icing Piping Nozzles Tips Cake Decorating Biscuits Sugarcraft Pastry Tool DIY ZH809 ( 4.46 $)
Bohemian gold and turquoise clip-on earrings ( 507.13 $) Roberto Cavalli
Solid color stylish elastic waist straight leg men's shorts ( 21.97 $)
Get more speed, free malware, registry Clean PC: Advanced PC Fixer
Peruvian curly weave human hair bundles peruvian curly hair wet and wavy human hair 3 bundles peruvian virgin hair natural wave ( 75.40 $)
Active stretchy skinny black and gray spliced women's pants ( 12.25 $)
Car radio mp4 mp5 player 1 din hd with rearview camera 4.1 inch video player bluetooth remote control stereo aux fm usb sd ( 46.58 $)
Sparkling women's long wavy light blonde synthetic hair wig ( 14.47 $)
Ios android app lcd display wirelesstouch screen keypad panel gsm pstn sms home security burglar voice alarm remote arm system ( 125.99 $)
Red Floral Pattern Woven Silk Tie ( 66.00 $)
Simplee Black ruffle warm winter coat Women turndown long coat collar overcoat female Casual autumn 2016 pink outerwear ( 46.65 $)
Aukey usb charger quick charge 3.0 3-port usb wall charger for lg g5 xiaomi samsung galaxy s6edge nexus 6p5x iphone ipad &more ( 34.66 $)
![109.png](http://projectgold.ru/img/adaliimg_e/109.png)
Discounts! the product review
![progect11.jpg](http://projectgold.ru/img/progect11.jpg)
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).
![buy.png](http://projectgold.ru/buy.png)
READ MORE
2016 new canvas waterproof travel bag mulitifun ctional out men women luggage men s backpacks bags ( 19.00 $)
Mens Cashmere Lined Brown Italian Leather Gloves ( 98.00 $)
4x UNIVERSAL MOTORCYCLE MOTOR BIKE TURN SIGNAL INDICATOR LIGHT LAMP BLINKER AMBER Arrow 3W ( 12.99 $)
Hot brazilian loose wave virgin hair 4bundle deals 7a rosa hair products human hair soft loose ( 87.15 $)
Transparent TPU Back Protective Cover Case for XiaoMi RedMi Note 2 ( $2.39 )
Tactical military boshile 10x50 navy binoculars with rangefinder and compass reticle illuminant telescope waterproof green color ( 117.50 $)
7a brazilian kinky straight hair with closure yaki straight hair weave coarse yaki human hair brazilian virgin hair with closure ( 95.14 $)
Androu Frej Game of Thrones
2016 New Luxurry Brand Car Key Wallet Purse Men Women Woolen Felt Keychain Holder Pocket Keys Organizer Pouch Case Bag ( 6.71 $)
Raffaello dark gray leather slip on shoe ( 127.10 $) D Acquasparta
2016 Women V Letters Saffiano handbags Women Leather Commuter Office Ring tote bag Women's Pouch Bolsas Famous Ladys V Flap bag ( 33.88 $)
Chispaulo cow womens genuine leather handbags female crossbody bags for women messenger bag lady real women ( 269.40 $)
Brazilian virgin hair body wave 8a brazilian body wave mink brazilian hair weave bundles human hair extension vshow hair company ( 48.00 $)
Yuan Black Set of 4 Extra Plates ( 72.00 $)
Uajzman, Frederik
![79bb.jpg](http://projectgold.ru/img/adaliimg_e/79bb.jpg)
Discounts! best spa products
![progect11.jpg](http://projectgold.ru/img/progect11.jpg)
Products which fall under this return policy can be returned domestically, as long as they are unused and in the original packaging. No questions asked!
If a product that falls under this guarantee is found to be counterfeit, you will get a full refund (shipping costs included).
![buy.png](http://projectgold.ru/buy.png)
READ MORE
Street style beam feet camo print loose fit lace-up parachute pants for men ( 26.32 $)
New kerui g19 pet against pir infrared security motion movement siren sensor detector home smart alarm system ( 113.99 $)
Midnight Blue Nylon Puffer Bow Tie ( 45.00 $)
7A Unprocessed Brazilian Virgin Hair Body Wave 3 bundles Brazilian Body Wave Virgin Hair Human Hair Weave Rosa Hair Products ( 50.25 $)
Shop Eat Village
V-neck button embellished short sleeve men's t-shirt ( 13.61 $)
Fashion women messenger bags handbag waterproof nylon shoulder bag crossbody bags for women casual tote bolsa feminina ladies ( 26.59 $)
Vernee Mars 4G Phablet ( 169.99 $)
Vtoraya zhizn Uve (film)
Red and Black Quilted Wallet On Chain ( 132.00 $)
30917 new fashion canni hot sale 239 colors 7 3ml names canni nail art soak off ( 2.85 $)
VICUNA POLO Unique Buckle Design Irregular Cover Open Mens Messenger Bag 2 Sizes Business Men Crossbody Bag Leather Man Bag Hot ( 31.64 $)
2pcs h7 light bulbs 3000k halogen h7 12v 55w golden yellow fog factory price car styling ( 2.99 $)
Universal Tripod Mount Adapter Telescopic Cell Phone Stand Holder ( $1.93 )
ESP8266 WiFi Wireless Module ( $3.33 )
![295.jpg](http://projectgold.ru/img/adaliimg_e/295.jpg)
Discounts! top 10 products 2017
![progect11.jpg](http://projectgold.ru/img/progect11.jpg)
![buy.png](http://projectgold.ru/buy.png)
![15.jpg](http://projectgold.ru/img/adaliimg_e/15.jpg)
#11
Posted 24/10/2017, 16:47
Find Acticin Low Price With Overnight Delivery levitra generico prezzo Costo Viagra In Farmacia Capecitabine Buy Tamoxifen Pct
Pharmists In Canada Cialis viagra Viagra Generico Eurofarma Keflex Breast Cyst
#12
Posted 30/11/2017, 10:25
#13
Posted 01/12/2017, 13:58
Hay Viagra Generico viagra online prescription Viagra Generique Le Moin Cher Levitra 5 Mg Contro L Impotenza
Viagra Alcool Mort Levitra Acquistare Impotenza viagra Dapoxetina In Natura Cialis 100 Mg
Prix Cialis En Espagne cialis Priligy Comprar Cheap Erectile Dysfunction Pills Cialis Que Tal
Kamini Sildenafil Oral Jelly Cialis Rythme Cardiaque viagra Authentic Cialis Where Can I Buy Discount Progesterone Medication Shop Levitra Verschreibungspflichtig
isotretinoin shop wheretobuylevitrapills Prix Cialis Pharmacie Paris
Acquistare Kamagra Strasburgo Sale Discount Cash On Delivery Acticin Oregon Lasix Overnight Shipping levitra order online Anti Oestrogene Homme Viagra Dapoxetine Reviews Nolvadex For Sale Amazon
What'S Better Penicillin Or Amoxicillin online pharmacy Cialis Tablets 20mg Amoxicillin And Azithromycin Zithromax How To Get Astelin Nasal Spray
Canada Law On Cialis Prescription online pharmacy Cialis 5 Mg Effets Indesirables Cialis 10 Mg Forum
Cheap Nexium Online No Prescription online pharmacy Comment Obtenir Du Viagra Sans Ordonnance
Cialis 20mg Avis Pediatric Keflex Dosing cialis online Alli Ordering In Canada
#14
Posted 03/12/2017, 13:43
Viagra Tablets Cialis Under The Counter viagra Canadian Cialis Without Prescription
Viagra Im Internet Bestellen Strafbar India Drugs Without Scripts Overnight viagra Priligy Niederlande Viagra Au Herbes Prednisolone India
Pharmacy Femera Airmail Levitra Ligne Kamagra Uk Next Day Delivery generic cialis Oral Jelly Kamagra Congestion Nasale Comprar Cialis En Farmacia
Cost For Viagra Without Insurance 283 viagra Keflex Dehydration
Costo Cialis 20 Mg Online Propecia Male Pattern Hair Loss On Sale Macrobid Next Day Delivery viagra Cytotec Temps Aldactone
#15
Posted 07/12/2017, 03:16
Furosemide Mexico Amoxicillin And Seasonique Propecia Effects High Blood Pressure viagra online prescription Over The Counter Gabapentin
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)