Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 8th Dec 2011, 12:51 AM   #1
Warrior Member
 
Join Date: 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
validating the long form fields
Share on: 
fb share twitter share gplus share more share

hello,

iam developing a website and i have a long form in tat. i have to validate all the fields. the method im using for validation is given below

if(document.getElementById('user').value==''){
alert ('please enter the valid username');
}

how can we add more than one field by this method (is ter any method tat we can write in single line).
amrta is offline  
Unread 8th Dec 2011, 04:04 AM   #2
Warrior Member
 
Roll3rBoX's Avatar
 
Join Date: 2011
Posts: 24
Thanks: 0
Thanked 3 Times in 3 Posts
Default
Re: validating the long form fields
Share on: 
fb share twitter share gplus share more share

not likely...different form elements need to be validated differently..!

Keep Watching this space...! something's gonna pop in here!
Roll3rBoX is offline  
Unread 9th Dec 2011, 02:43 AM   #3
Warrior
 
Join Date: 2011
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: validating the long form fields
Share on: 
fb share twitter share gplus share more share

Use JQuery,
rajprince is offline  
Unread 10th Dec 2011, 08:58 AM   #4
Active Warrior
War Room Member
 
Join Date: 2011
Location: the Netherlands
Posts: 63
Thanks: 10
Thanked 10 Times in 10 Posts
Default
Re: validating the long form fields
Share on: 
fb share twitter share gplus share more share

The previous answer use jQuery is the best answer.

If for whatever reason you don't want to use jQuery the alternative is as follows:

Create a javascript function for checking the value of a field and return true of false based on wether or not the required field is checked

Create an array containing all element names of the required fields you need to check

create a loop iterating over every element name in the array and calling the function you created. If false break out of the loop and display an error message.

Good luck. If nessescary PM me.
dutchguy is offline  
Unread 12th Dec 2011, 06:54 AM   #5
Active Warrior
 
Join Date: 2011
Posts: 43
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Re: validating the long form fields
Share on: 
fb share twitter share gplus share more share

The best option is jquery but if you want to use your own way then use if else condition also very easy.

ricky pounting is offline  
Closed Thread


Bookmarks

Tags
fields, form, long, validating


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 08:35 AM.