Many times we come to same problem which we faced so many times. But still when web developer comes in sitution of checking forms with simple javascript.
He started looking into some solutions. Some people try to use the some third party JS library like (Mootools, Jquery, lightbox, Prototype and etc…)
I recomend not to use these JS library because these library will take some brandwidth of your website. Most of the code these JS library is useless or un useful to your website.
Still you are adding these JS library to your website.
In this article I will show you very easy technique to the javascript form validations with minium code.
Just copy paste the following code in to your head section first.
<script type="text/javascript">
// Set maxlength value for your required fields
var maxlength = 255;
/*
* You can pass three parameters this function
* Example : ValidateRequiredField(phone,"Telephone must be filled out!", "number");
* For string format no need to pass any strFormat.
*/
function ValidateRequiredField(field,alerttxt,strFormat) {
with (field) {
if (value == null|| value == "") {
field.style.background= "grey";
alert(alerttxt);return false;
} else if (value.length > maxlength ) {
field.style.background= "grey";
alert('Maxlenth should be not more than 255 charactor');return false;
} else if (strFormat == 'number' && isNaN(value) ) {
field.style.background= "grey";
alert(field.name + ' is not a number, Please put in Numric format');return false;
} else {return true;}
}
}
/*
* Using the function you can validate the email functions
* Example: ValidateEmailAddress(email,"Email is not in Valid format!")
* Return true or false
*/
function ValidateEmailAddress(field, alerttxt) {
with (field) {
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos < 1 || dotpos-apos < 2)
{alert(alerttxt);return false;}
else {return true;}
}
}
/*
* Using the function you can validate the checkbox in the form
* Example: ValidateCheckBox(agreement,"Agreement is not checked!")
* Return true or false
*/
function ValidateCheckBox(field,alerttxt) {
with (field) {
if (!field.checked == 1) {
alert(alerttxt);return false;
} else {return true;}
}
}
/*
* Using the function you can validate the checkbox in the form
* Example: ValidateRequiredField(website,"Website name is required!")
* Return true or false
*/
function ValidateWebAddress(field,alerttext) {
with(field) {
var companyUrl = value;
var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
if(RegExp.test(companyUrl)) {
return true;
} else {
alert(alerttext);
return false;
}
}
}
function ValidateCompleteForm(thisform) {
with (thisform) {
if (ValidateRequiredField(full_name,"First name is required!")== false) {full_name.focus();return false;}
if (ValidateRequiredField(email_address,"Email must be filled out!")== false) {email_address.focus();return false;}
if (ValidateEmailAddress(email_address,"Email is not in Valid format!")== false) {email_address.focus();return false;}
if (ValidateRequiredField(website_name,"Website name is required!")== false) {website_name.focus();return false;}
if (ValidateWebAddress(website,"Website Address is not incorrect format!")== false) {agreement.focus();return false;}
if (ValidateRequiredField(mobile,"Mobile must be filled out!", "number")== false) {phone.focus();return false;}
if (ValidateCheckBox(sex,"sex is not checked!")== false) {sex.focus();return false;}
}
}
</script>
And in you body where you are using the form just add the onsubmit=”return ValidateCompleteForm(this)” words in Form tag.
Exmaple:
<form action="submit.php" onsubmit="return ValidateCompleteForm(this)" method="post" >
Note: you can change the parameter as per your form fields names. Maxlength I kept 255 you can change this value as per your requirment.
Still if you have any doubts about this function please ask me.
Incoming search terms:
- complete form validation in javascript
- complete form validation using javascript
- full form validation in javascript
- checkbox validation in javascript with example
- checkbox validation in javascript example
- javascript complete form validation
- checkbox validation in javascript
- Complete form validation
- javascript form checkbox validation
- javascript simple checkbox validation form
- javascript complete form validaitonnnn
- full form validation javascript code
- how to do form validation in java script
- how to do form validation in javascript
- how to do form validation using javascript
- java script form validation example with source code
- javascript form validation
- complete javascript form validation code
- email validation complete in javascript
- wordpress plugins javascript validation







hey this blog is great. I’m glad I came by this blog. Maybe I can contribute in the near future. PM ME on Yahoo AmandaLovesYou702
Very nice article.. Thanks for sharing..
What template are you running on this site ? I really like it. Could you post where you got it from ?
I Created this wordpress theme myself…If you want this then contact me on wordpressapi@gmail.com
I want you to know, your writing goes to the nerve of the issue. Your pellucidity leaves me wanting to know more. I am going to immediately grab your feed to keep up to date with your site. Sounding Out thanks is simply my little way of saying what a masterpiece for a fantastic resource. Let In my dearest wishes for your future post.
Thanks for this. I will try it on my on.
I think this website is a great idea. I agree with you on most things.
Neat website here, I am a web designer myself and found some neat design ideas from this.
What is a capta code? Can anyone provide me plug in for this one.Thanks in advance
You have really great taste on catch article titles, even when you are not interested in this topic you push to read it
Hi there… I really needed to thank you for sharing your ideas with us all. After checking out this blog, I’m your opinions regarding those recent attacks in Nigeria. Many thanks
Definitely worth applying. We are looking to showcase things that are innovative.
Hey very nice blog!! I will bookmark your blog and take the RSS feeds also
Hey, found your site by accident doing a search on Google but I’ll definitely be coming back. – He that is of the opinion money will do everything may well be suspected of doing everything for money. – Benjamin Franklin 1706 – 1790
Hey, that was without a doubt an interesting article. I had actually been looking for a photo printing related blog for a while now. Great! I have a similar blog, how much do you charge for advertising? because I can’t seem to find the information anywhere.
I am not doing any advertising on my blog right now…If you are interested then write to me on wordpressapi@gmail.com
Thanks for this excellent blog.
Nice information, I really appreciate the way you presented.Thanks for sharing..
This is a good write-up, I was wondering if I could use this piece on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away.
In looking for web-sites related to internet hosting and particularly comparison hosting linux strategy internet, your web page came up.
Great discussion. And I REALLY like that you practice what you preach. That’s when you can tell a post has come together.
].
And I’m also fascinated by how fresh you made the routine [admit it: what you just shared has been regurgitated millions of time.
Ben Johnson said people don’t need taught as much as they need reminding.
Good work.
I genuinely enjoyed reading through this post.Thank you.
bookmarked your post will impute to this latter . Regards, Mike
hi it is my first post on this blog and to start with I would like to thank you for the great information, which I were able to find in this and all previous topics , it really helped me a lot. I will definitely add this website on my rss reader
Also, I would like to ask – don’t you mind if I will quate some information from your blog since I am writing articles for the Bukisa, Ezine and other articles directories (this is my part time job)? It would really help me with some of mine articles. Of course, I will mention your website title or URL (not all articles directories allows URL’s , so I can’t 100% promise that you will get a direct backlink to your blog).
Hello, Good morning as i so love your nice site, I would be very glad if you would like to me blog a big review about your blog in this little would you grant me permission? Reseller Hosting
This is a superb blog, I found your website researching bing for a similar theme and came to this. I couldnt find to much additional information on this write-up, so it was wonderful to find this one. I will probably end up being back again to check out some other posts that you have another time.
Hi, I like your views. I was also thinking in the same way. Please write some more on similar topics and continue posting new ideas. Thank you.
thankyou lots, I must comment that your website is amazing!
Very good information, thanks for sharing.
Awesome page it really helped my project.
Hey – perceptive blog, reasonable looking yon some blogs, seems a fair amicable stage you are using. I’m currently using WordPress with a view a two of my sites but looking to convert equal of them over to a platform correspond to to yours as a trial run. Anything in particular you would counsel about it?
Can you post more about this please if possible and let me know by emailing with subject Rey Youns?
Hello Guru, what entice you to submit an write-up. This write-up was really interesting, in particular since I was checking for thoughts on this subject last Thursday.
You own a very interesting blog covering lots of topics I am interested as well.Just bookmarked your blog to continue reading in the next days… Please continue your marvellous work
This is a nice blog, Going On.
Are you joking? I’m not sure I can put myself behind what you have said. But I will definitely be back to find out more soon.
I must say that it’s a very interesting article. I get a lot of knowledge from here. Beside that, your blog is so popular among the searchers from search engines. It means yours is great!
I want to say your blog is almost amazing, bye, Hermina Irestone
Totally digg your website thanks a lot for the info
Wo…Nice Blog, Nice tips, Great article!, I have recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work. Well Come Back To My Blog [url http://www.ipadzu.net
I had trouble viewing in Chrome but it works fine in Mozilla. Anway, the information is good. I am very happy to have discovered this.
Excellent job.
All extremely true, but I don’t agree myself. I will stick the more conventional view. But I certainly support your right to have your own point of view. Interesting anyway.
Im grateful for the blog.Much thanks again. Much obliged.
Your work has always been a great source of inspiration for me. I refer you blog to many of my friends as well.
Thanks, I’ve been reading a lot of similar articles lately.
Awesome stuff. You made a really nice compilation. Thanks!
Your blog is so informative ¡ keep up the good work!!!!
Was an interesting article, thank you..
Heck, I was totally impressed with that. I told my partner and she agreed with me. I would like to hear more on this. Cool!
Hello, I like your article. This is a cool site and I wanted to post a comment to let you know, nice job! Thanks Meme
[url vuitton
Superb. It’s the same here in Phoenix. Can be remarkably frustrating, but that’s life in this day and age.
Hello, I like your website. This is a good site and I wanted to post a comment to let you know, nice job! Thanks Jessica
[url vuitton
Thanks for writing. I worked a lot of work
We looked whole internet to post regarding to this subject. Thanks alot
My sister checked whole internet to grapcomments about to this area.. Thanks alot
Hey admin , Why dont u put facebook badge on your site? Because I want to add your fb. Thank’s Regards Owner of kabarpapua.com
You definitely nailed that one on the head!
I just wanted to comment and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more in the future
As a Newbie, I am always searching online for articles that can help me. Thank you
This is a excellent post, but I was wondering how do I suscribe to the RSS feed?
Please click on right side email icon for subscribe the RSS feed.
I am quite interesting in this topic hope you will elaborate more on it in future posts
This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
Hayadministrator I like with ur post . May i save this posting for my examination ? thanks adminstrator
Awesome content. I continuously come across really distinctive discussions here on your webpage.
I wanted to thank you for this interesting I definitely loved every little bit of it. I have you bookmarked your site to look at the latest stuff you post.
Nice Info . Do you mind if I talk about this post in my blog. You and your blog will surely get the credit
I love your website! did you generate this your self or did you outsource it? Im trying to find a blog design thats comparable so thats the only reason I’m asking. Either way maintain up the good work I was impressed with your content really..
Hi, When I add a web-page to my Favorites in IE8, it is added end of it of the already established list. I will sort them by name*manually. But I’d like IE8 to try this automatically. Is this done ? Thanks
Hi. I wanted to thank you for the good facts you’ve posted on your website. I will definitelycome back to check it out again and have subscribedto your RSS feed. Have an excellent day.
Hi, truly love the design of one’s website. Would you mind telling me what theme you happen to be utilizing? I’m new to this and I’m hoping to obtain mine searching anywhere near as cool as yours. Thanks a great deal.
Admirable weblog! I’ll probably be referencing some of this details in my next speech. I would appreciate it when you visited my weblog at
Thanks…for your appreciation
Thanks for sharing javascript code to minimize our work.
thanks for your replay
I’m curious to find out what blog system you have been utilizing? I’m experiencing some small security issues with my latest website and I’d like to find something more safeguarded. Do you have any recommendations?