www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26

Thread: Javascript validation help

  1. #16
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="stylesheet.css" rel="stylesheet" type="text/css">
    <title>Client Validation</title>
    <head>
    
    </head>
    
    <body>
    		<center>
    			<form name="custInfo" id="custInfo" autocomplete="on">
    				<fieldset>
    				<legend>Required Customer Information</legend>
    					<label>First Name:<input id="firstName" name="name" type="text" placeholder="Forename" autofocus></label>
    					<label>Surname:<input id="Surname" name="sName" type="text" placeholder="Surname"></label>
    					<label>Telephone:<input id="tel" name="telephoneNum" type="tel" placeholder="07123456789"></label>
    					<label>Email Address:<input id="emailer" name="email" type="email" placeholder="email@email.com"></label>
    					<br />
    					<input type="button" value="Submit!" onclick="isValid()" />
    				</fieldset>
    			</form>
    		</center>
    <script src="javascript.js" type="text/javascript"></script>
    </body>
    </html>

  2. #17
    Join Date
    May 2012
    Posts
    12
    Ah!

    Now I understand what Padonak meant by the Javascript needing to be underneath the form.

    Thankyou very much for pointing that out an thanks for the replies and help everyone. Much appreciated.

  3. #18
    Join Date
    May 2012
    Posts
    12
    Could someone please explain this line to me. Don't really understand it very well -

    Code:
    function gPD(element){var left=element.offsetLeft,top=element.offsetTop;for(var parent=element.offsetParent;parent;parent=parent.offsetParent){left+=parent.offsetLeft;top+=parent.offsetTop;}return{left:left,top:top,width:element.offsetWidth,height:element.offsetHeight};}

  4. #19
    Join Date
    Feb 2011
    Posts
    83
    Padonak's code is absolutely brilliant.

    Can you go further to change the telephone number to format 123-555-2345 x 7890? When you type the first three area code, it automatically moves to the first 5 so you can type another three then region code, then moves to 2 so you can type last four then moves to 7, so you can type none, or 1, 2, or 3 or 4 digits. Is this possible?

    Thanks for your brilliant code, Padonak

  5. #20
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    i am not familiar with such phone numbers structure we have another way of writing in Russia:

    (8987)123-4567

    where the first(bold) 8 inside the brackets is always 8. first i need to know everything about your phone numbers format. and by the way i must warn you that i am not a professional coder, coding is just a hobby for me, and my scripts may not be as good as if written by a professional coder

  6. #21
    Join Date
    Feb 2011
    Posts
    83
    Hi Padonak, your code looks great. You can go with the format as (nnn)nnn-nnnn x nnnnn, or nnn-nnn-nnnn x nnnnn, n represnts a digit. The x means extension. The last four or five after x can be none, or one up to 5 digits, it's optional.

    Thanks for your wonderful code,

  7. #22
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    ok i'll try )

  8. #23
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    just don't ask for 3d edition
    Attached Files Attached Files

  9. #24
    Join Date
    Feb 2011
    Posts
    83
    Thank you so much, Padonak, your code is absolutely wonderful!

  10. #25
    i tested the page in Opera, Safari, Chrome, IE and FF before posting the code I have a simple form wrote up, completely unstyled and plain which you shall see below. What I need to do is for the phone number and email address fields, is to validate whether the correct string is in the fields (numbers/amount of numbers for phone number and whether the email address is valid)

    www.automateandvalidate.com

  11. #26
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    Jamewallace, feel free to take the code discussed above and fit it to your needs

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles