| | |
javascript form validation
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi there!
i've got an html form and i want to make sure some fields are not empty before it gets submitted. i've read many examples and i've written some code but i have no idea why it doesn't work (it's as if the javascript script didn't exist). i don't know if it matters but i use php and it's a self submitting form. here's my code:
and a part of the form:
thanks for your help
i've got an html form and i want to make sure some fields are not empty before it gets submitted. i've read many examples and i've written some code but i have no idea why it doesn't work (it's as if the javascript script didn't exist). i don't know if it matters but i use php and it's a self submitting form. here's my code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script language="javascript" type="text/javascript"> function notEmpty(){ If (document.email.eponimo.value.length==0) { alert("some message"); document.email.eponimo.focus(); return false; } return true; } </script>
and a part of the form:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<form id="form" name="email" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return notEmpty()" enctype="multipart/form-data" method="post" > <input type="text" name="eponimo" size="35" /> <input id="btn" name="Submit" type="submit" value="ΑΠΟΣΤΟΛΗ" />
thanks for your help
Hi,
try this for now:
try this for now:
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- function notEmpty() { var _form = ( "form" in document ) ? form : document.getElementById("form"); if ( _form.eponimo.value ) { return true; } alert( "field cannot be empty!" ); _form.eponimo.focus(); return false; } //--> </script>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- Javascript form validation to PHP processing (JavaScript / DHTML / AJAX)
- URGENT! JavaScript form Validation (JavaScript / DHTML / AJAX)
- javascript Form Validation Libraries (JavaScript / DHTML / AJAX)
- Really Stuck - ASP/Javascript Form Validation (ASP)
- JavaScript form validation - please help (JavaScript / DHTML / AJAX)
- javascript required fields 290 form elements (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: javascript help
- Next Thread: select/save selected records
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta browser captchaformproblem cart checkbox child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype redirect runtime safari scale scriptlets scroll search security select shopping size software toggle unicode w3c web windowofwords wysiwyg \n





