Form validation

  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Ok at the moment i am making a form that can email anyone by them putting in a subject, email addy and message but i need to have it validated is there any way someone can give me a simple validation script in javascript?
D7
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

are you writing the form in html? php?
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Only HTML i'm afraid its a lot easier than php to do at the moment lol
d7
  • guitrspaz
  • Graduate
  • Graduate
  • guitrspaz
  • Posts: 106
  • Loc: Baltimore, MD

Post 3+ Months Ago

I don't know of a way to require form items with HTML, but you could try formmail.pl http://www.formmail.com its really easy to set up and you can specify required fields very easily
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

<script>

function emailvalidation(entered, alertbox)
{
// E-mail Validation by Mediadesign / Mediadesign-House
// Please do not remove this line and the line above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value Validation by Mediadesign / Mediadesign-house
// Please do not remove this line and the line above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit Validation by Mediadesign/ Mediadesign-House
// Please do not remove this line and the line above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i")
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Mediadesign / Mediadesign-house
// Please do not remove this line and the line above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function formvalidation(thisform)
{
// This function checks the entire form before it is submitted
// Note: This function needs to be customized to fit your form
with (thisform)
{
if (emailvalidation(Email,"Illegal E-mail")==false) {Email.focus(); return false;};
if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(Whatever,"The textfield is empty")==false) {Whatever.focus(); return false;};
}
}
</script>
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

nice code media! did you write it?

either way, I've saved it to my archives. ;) thx :D
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

that's me you've writed the script don't modify the copyright (c) :wink:
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

oh i would never! cuz i'd just mess it up anyway hehe 8)

nice code sir.
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

i hope to be more useful for all of us :lol:
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

lol thanx media i'm sure what you have written is a lot better than the poor javascript code i did :P
d7
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

whooooo thats a long script...somewhere I have a small validation form, just check for something like:
Code: [ Select ]
if ($field == "" || " ") {
   echo("Please fill in the $field");
}
  1. if ($field == "" || " ") {
  2.    echo("Please fill in the $field");
  3. }


Thats really really simple in PHP basically the same in javascript. However use media's his is much more extensive and probably alot better then that :P. So just use it, and don't change his copywrite :-D
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

haha

amazing how small that is compared to the other. heheh
I love this stuff, where there's a million ways to do the same thing.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

if you wanted to get real complicated you could validate emails by search a string for "@" and "." to see if they entered a valid email.....all depends on the case tho.
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

why not creat ozzu web site .... all of us will start up his help in
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

What?! I have no idea what that is supposed to mean MediaDesign. I think you need to work on your English a bit more. I am sorry to say this, but I will start deleting your posts if they make no sense, so please try harder to get your English right, as it just causes confusion for me and many members here if we have no idea what you are saying.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I think what he might be reffering to is that ozzu.com is just a forums page. He might want a script help page, similar to http://www.bigwebmaster.com.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Hmm, not sure how you interpreted that from his sentence lol.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I think it went like this:

Code: [ Select ]
why not creat ozzu web site .... all of us will start up his help in
Why not create an Ozzu website? All of us at this forum could start it up and pitch in.
  1. why not creat ozzu web site .... all of us will start up his help in
  2. Why not create an Ozzu website? All of us at this forum could start it up and pitch in.
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

i supose you are from usa am not british & am not living in usa ,, ok if si tu veux faire le clown fais le chez ta mémé moi je donnes des exemples pour des gens qui en on besoin si non va te faire baisé sale petit fils de putte [fade]:lol: :lol: :lol: :lol: :lol: [/fade]
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I take it your from france then? ok well then, nous vous apprécions contribuant à la communauté, mais parfois votre anglais est très caché.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Je conviens. Svp juste essai plus dur.
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

ok , si c'est comme ça bon je n'ai plus rien a ajouté :oops:

juste qu'il faut savoir resté calme et sympa avec les gens chers Monsieurs , Next Week I'll Pay 12 Month At ALC American Language Center !
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

i'm not exactly sure what to think about this thread any more...
  • MediaDesign
  • Loser
  • Loser
  • User avatar
  • Posts: 129
  • Loc: somewhere

Post 3+ Months Ago

that's too long to explain
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

indeed. consider me uninformed then...

Post Information

  • Total Posts in this topic: 25 posts
  • Users browsing this forum: No registered users and 64 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.