Up vote 2 down vote favorite share g+ share fb share tw.
My below mentioned code still submits form on special character in name field. Validation works but If I submit repeatedly it breaks and submits the form with special chars in name. What could be the reason for this?
$("#fee"). Submit(function(){ trimmedValue = $. Trim($("#name").val()); $("#name").
Val(trimmedValue); typevalue = $("input:radio@name='type':radio:checked").val(); if(typevalue=="FLAT" &&! IsFloat($("#amount").val())) { alert("Amount should be number with proper decimal formatting"); $("#amount"). Val("0.0"); return false; } var noSpecialChars = /^a-zA-Z0-9/g; if (noSpecialChars.
Test($("#name").val())) { alert("Please enter valid fee Name. Do not enter special characters" ); return false; } if(typevalue=="PERCENTAGE" &&! IsFloat($("#percentage").val())) { alert("percentage should be number with proper decimal formatting"); $("#percentage").
Val("0.0"); return false; } if(typevalue=="FLAT" && $("#amount").val()=="0.0") { return confirm("Do you really want the amount to be 0.0? "); } if(typevalue=="PERCENTAGE" && $("#percentage").val()=="0.0") { return confirm("Do you really want the percentage to be 0.0? "); } }); jquery form-validation input-validation link|improve this question asked Aug 27 '09 at 13:01Ketan Khairnar3572310 50% accept rate.
I did it on Firefox 3.5.2, but couldn't reproduce it on IE 6.0. After exploring some more, I noticed that in this line ... if (noSpecialChars. Test($("#name").val())) { ... the call to .test() was returning true, then false, in an alternating pattern (in Firefox only) suggesting some problem with the RegExp.
So I tried replacing the implicit creation of the RegExp like this: //var noSpecialChars = /^a-zA-Z0-9/g; var noSpecialChars = new RegExp("^a-zA-Z0-9"); And that fixed the problem for me.
Thanks this fixed the issue. Would like to know how to debug in this scenarios. – Ketan Khairnar Aug 27 '09 at 14:38 No problem - in this case I debugged it in a pretty low-tech fashion, by adding a textarea element to the page and writing the result of noSpecialChars.
Test($("#name").val()) to that textarea. I also used Firebug a bit to discount some early hypotheses. – Jeff Sternal Aug 27 '09 at 14:42.
It appears that the interpreter is never reaching return false; on pressing repeatedly and is instead submitting the form to the href specified for the form. If you have an href in your form tag, try removing it and inserting the property just before return is called.
I don't have href attribute for form. I have added action as well as method attribute. – Ketan Khairnar Aug 27 '09 at 13:19.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.