www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to identify the field type in javascript

Threaded View

  1. #1
    Join Date
    Jan 2006
    Posts
    10

    How to identify the field type in javascript

    Hi all,
    I am getting all the field name in the form and i am passing the fieldname to the javascript function in order to validate the fields.In the function i am checking each value based on the type.
    var a =document.forms[0].fname.value
    b=a.split(",");
    for(i=0;i<a.length;i++) {
    type=eval('document.forms[0].'+a[i]+'.type');
    if(type=="text")
    alert("the field type is a text") //working fine
    if(type=="select-one")
    alert("the field type is select one") //working fine
    if(type=="select-multiple")
    alert("the field type is select multiple") //working fine
    if(type=="radio")
    alert("the field type is radio") //this is not working fine
    }

    I think for radio type,checkbox i should check as
    document.forms[0].radiogroup[0].type


    but i don't how to check with my code
    Could anyone say how to check for the field type for radio button or could anyone say how to check if the field type is a single /multiple

    Thanks in advance
    paula j
    Last edited by paula j; 03-02-2006 at 11:33 PM.

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