validation of file input type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhavanirayala
    New Member
    • Jul 2007
    • 25

    validation of file input type

    Hi All,

    I am doing the validation of a file type.The form is not submitting to next page.
    My code is:
    [HTML]<script>
    function validateform(){
    if(document.tes t.browse.value= =' ' ){
    alert("please enter the value");
    document.test.b rowse.focus();
    return false;
    }
    else {
    if(confirm("sub mit this form")) {return true;}
    else {return false;}
    }
    }</script>


    <BODY>
    <form name=test action="showcon tents.jsp" onsubmit="retur n validateform()" >

    file :<input type=file name=browse>
    <input type=submit name=submit value=Submit >
    </form>
    </BODY>[/HTML]

    I didnt understand why this is happening...
    Can anyone please help me.
    Last edited by acoder; Aug 21 '07, 06:25 PM. Reason: Code in tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Please use CODE tags when posting code. Thanks.

    Move the confirm outside. Try replacing the else block with:
    [CODE=javascript]else {
    return confirm("submit this form?");
    }[/CODE]

    Comment

    Working...