Originally posted by Death Slaught
Simple js validation not firing.
Collapse
X
-
Oh sorry. Then sense his script is loading fine doesn't that meen that all he needs to do is enable the user to submit it. Because it works fine for me except I can't type anything in do to the readonly.Originally posted by acoderSee post #3, line 149 ...
Thanks,
{\_/}
(' . ')
(")[DEATH](")
(")(")
Comment
-
I just forgot that a developer should never have a "i quit" attitude...Than ks for reminding me that...Ok 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?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
-
Lol, good attitude!Originally posted by ajosI just forgot that a developer should never have a "i quit" attitude...Than ks for reminding me that...
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?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
-
yup 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.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
-
It 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.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
-
What ive done is, got the html generated from the view source of the jsp pageOriginally 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
-
I had some struts-html tags in my jsp page, changing them to pure html tags also didnt help :(. But when i connect this script to any other page it runs fine. I'm beginning to run out of ideas here.Originally posted by acoderLook at the generated source for your JSP. See if it's any different from the HTML page.Comment
-
Ok now ive managed to run the validation by changing the js code and doing some modification in my jsp page..But for some reason the page is not getting submitted after validation.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
-
I didn't know that. You're talking about the Java/JSP compiler, right? Anyway, a simple solution in the end. Glad to hear that it's working now.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