Originally posted by Death Slaught
Simple js validation not firing.
Collapse
X
-
Originally posted by acoderSee post #3, line 149 ...
Thanks,
{\_/}
(' . ')
(")[DEATH](")
(")(")
Comment
-
Originally posted by acoderI don't like to see a problem unsolved, but if you're happy, we'll leave it there :)
here is once again my js file--->
[CODE=javascript]
function everything(form )
{
var errors=0;
if(!isdate(form ))
errors++;
if(!isdate2(for m))
errors++;
if(errors==0)
return true;
else
{
compose(form);
return false;
}
}
function compose(form)
{
var text= "You forgot to fill in correctly:"
if(isdate(form) ==false)
{
text += "\nFrom Date"
}
if(isdate2(form )==false)
{
text += "\nTo Date"
}
alert(text)
}
function isdate(form)
{
if(form.fromDat e.value =="")
{
return false
}
else
{
return true
}
}
function isdate2(form)
{
if(form.toDate. value =="")
{
return false
}
else
{
return true
}
}
[/CODE]
and my jsp page(small portions) is like--->
[HTML]<script type="text/javascript" src="expen2.js" ></script>[/HTML]
[HTML]<form name="expenqryF orm" method="post" action="/publicity/ExpenQryAction. do" onsubmit="retur n everything(this );">[/HTML]
[HTML]<input type="text" name="fromDate" maxlength="8" size="8" value="">[/HTML]
[HTML]<input type="text" name="toDate" maxlength="8" size="8" value="" readonly="reado nly">[/HTML]
[HTML]<input type="submit" name="thesubmit " value="Submit">[/HTML]
Once again thanks for being patient and helpful. :)
regards,
ajosComment
-
Originally posted by ajosI just forgot that a developer should never have a "i quit" attitude...Than ks for reminding me that...
Originally posted by ajosOk now back to that problem...I just placed the js file to my jsp directory and when i checked my firefox error console i got an error---everything is not defined....What does this mean?Comment
-
Originally posted by acoderLol, good attitude!
The only thing I can think of is that it can't find everything() which means that the file hasn't been found. Is the file called expen2.js?Comment
-
Originally posted by ajosyup the file is called expen2.js....It s strange that the file cannot be found, coz ive done similar to some other pages and it works fine.Comment
-
Originally posted by acoderIt must be something small that no-one's noticed so far. Can you link to a test page? If not, can you produce a minimised client-side version (no JSP, just HTML/JS) that demonstrates the same problem.
and tested with the js file with the html generated.
when i change my view source generated html to this-->
[HTML]<input type="button" name="thesubmit " value="Submit" onClick="everyt hing(this.form) ">[/HTML]
It works fine but not on my jsp. i.e it works with plain html page and not with my jsp page. Strange.Comment
-
Originally posted by acoderLook at the generated source for your JSP. See if it's any different from the HTML page.Comment
-
Originally posted by acoderIs this code online? If so, post the link. If not, post the JSP page's HTML (view source in the browser), not a HTML page.
[CODE=javascript]
function everything(form ) {
isfromDate(form )
allblanks(form)
}
function allblanks(form)
{
if(isfromDate(f orm))
{
form.submit()
}
if(isfromDate(f orm) == false)
{
compose(form)
}
}
function compose(form) {
var text = "You forgot to fill in correctly:"
if(isfromDate(f orm) == false) {
text += "\nDATE"
}
alert(text)
}
function isfromDate(form )
{
if(form.fromDat e.value == "") {
return false
}
else {
return true
}
}
[/CODE]
my revised html button is
[HTML] <input type="button" name="thesubmit " value="Submit" onClick="everyt hing(this.form) "> [/HTML] .
Last hurdle i suppose ;). Thanks for being patient with me as ive found out how nasty a beast is javascript to debug.Comment
-
Hey acoder ive successfully run the page..one of the problem turned out that my compiler wasnt too happy with my decision to name my jsp page and js file as one, have you heard of it before??. Thank you for the support and encouragement, if it wasnt for you i wouldnt had learnt this. Thanks buddy:).Comment
-
Originally posted by ajosHey acoder ive successfully run the page..one of the problem turned out that my compiler wasnt too happy with my decision to name my jsp page and js file as one, have you heard of it before??. Thank you for the support and encouragement, if it wasnt for you i wouldnt had learnt this. Thanks buddy:).Comment
Comment