| | |
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 |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically browser bug calendar captchaformproblem cart checkbox child close codes createrange() cursor date debugger dependent disablefirebug dom dropdown editor element embed engine enter events explorer ext file firefox form forms frameworks getselection google gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump libcurl maps masterpage math media microsoft object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post programming progressbar prototype redirect regex runtime safari scale scriptlets scroll search security shopping size software sql text textarea unicode web website windowsxp wysiwyg \n





