By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

verify info in order fom

P: n/a
i am looking for help on how to verify information in a form so that
the following info has to be filled in before they click on submit. I
am not an expert in java or html so any help would be greatly
appreciated.

Name
Address
City
State
Zip
Email
Phone

p.s.-The page that this info is on is an .html page.

Sep 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
<jo***@jtphotoservice.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
i am looking for help on how to verify information in a form so that
the following info has to be filled in before they click on submit. I
am not an expert in java or html so any help would be greatly
appreciated.

Name
Address
City
State
Zip
Email
Phone

p.s.-The page that this info is on is an .html page.


To what extent do you want to verify the data?

Some validation tests include:
a) minimum number of characters.
b) presence/absence of certain characters.
c) drop-down lists to ensure validity; (e.g. State).

Regular expressions are often used for some items.

If someone wants to put in bad data they can:

John Q. Public
12345 Archer Avenue
Lemont
IL
60439
jq*@aol.com
630-685-0000

Is the above valid or not? How can you tell?
Sep 22 '05 #2

P: n/a
ASM
jo***@jtphotoservice.com wrote:
i am looking for help on how to verify information in a form so that
the following info has to be filled in before they click on submit. I
am not an expert in java or html so any help would be greatly
appreciated.

Name
Address
City
State
Zip
Email
Phone

p.s.-The page that this info is on is an .html page.


if you use only text fields

<script type="text/javascript">
function verif(aForm) {
for(var i=0;i<aForm.length;i++)
if(aForm[i].type == 'text' && aForm[i].value=='')
{
alert('Field : '+aForm[i].name+' is empty');
aForm[i].focus();
aForm[i].select();
return false;
}
return true;
}
</script>

<form onsubmit="return verif(this)" blah >

--
Stephane Moriaux et son [moins] vieux Mac
Sep 22 '05 #3

P: n/a
just so that the boxes aren't left blank...if the info they enter is
wrong, i will deal with that seperately

Sep 22 '05 #4

P: n/a
so would i have to change this line

alert('Field : '+aForm[i].name+' is empty');

to where "name" is replaced with "address", "phone", and so on.

i know how to create pages but i am new to all the stuff that happens
behind the scenes so to speak.

Sep 22 '05 #5

P: n/a
ASM
johnt wrote:
so would i have to change this line

alert('Field : '+aForm[i].name+' is empty');

to where "name" is replaced with "address", "phone", and so on.
here 'name' is the name of the field (the input type=text)
that's to say : 'Name', 'Address' 'Phone' or whatelse you did

so this alert displaies automaticaly the right message
then the right field is reach and shown
then submit is stoped
(except if something was entered in the field)
i know how to create pages but


you have only to copy-paste what I have given
in html code of your page (*)
Don't forget the onsubmit=blah in your tag 'form'

nothing more to add and anything to change
if you only need to prevent blank fields

do that and try it
(*) beter to put the javascript in header
but it can be anywhere you want

--
Stephane Moriaux et son [moins] vieux Mac
Sep 22 '05 #6

P: n/a
JRS: In article <11**********************@g44g2000cwa.googlegroups .com>
, dated Thu, 22 Sep 2005 06:41:53, seen in news:comp.lang.javascript,
jo***@jtphotoservice.com posted :
i am looking for help on how to verify information in a form so that
the following info has to be filled in before they click on submit. I
am not an expert in java or html so any help would be greatly
appreciated.


Firstly, read the newsgroup FAQ; all of it. By the time you get to the
end, you should have learned that Java is not javascript.

For field validation, see
<URL:http://www.merlyn.demon.co.uk/js-valid.htm>.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.