Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
HTML Pages with CSS and JavaScript
js form validation
Mary Wallace
Ranch Hand
Posts: 138
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have a form to validate email address and texbox. The email validation is not working. Below is my code. Can someone help me !!
var testresults function checkemail(){ var str=document.claims.email.value var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ alert("Please input a valid email address!") testresults=false } return (testresults) } function testscript(frm) { var tmplen; var tmpvalue = new String(document.claims.comments.value); tmplen=document.claims.comments.value.length; tmpvalue=tmpvalue.substr(0,1000); if (tmplen >=1000){ document.claims.comments.value = tmpvalue; window.alert("Number of characters is limited to 1000"); } } function ValidateForm(claims) { if(IsEmpty(claims.comments)) { alert('You have not entered any comments') claims.comments.focus(); return false; } function checkbae(){ if (document.layers||document.getElementById||document.all) return checkemail() else return true } return true; } function IsEmpty(comments) { if ((comments.value.length==0) || (comments.value==null)) { return true; } else { return false; } }
Eric Pascarello
author
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You have a function inside a function.
Remove the function amd its closing bracket...
function checkbae(){
Eric
Mary Wallace
Ranch Hand
Posts: 138
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks Eric. As per your suggestion I remvoved the function inside the function.
And in form submission
onsubmit="javascript:return ValidateForm(this);return checkbae()"
But checkbae is not doing anything
Eric Pascarello
author
Posts: 15385
6
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
AHHH
I was not awake when I looked at the code
keep it the way you had it initially! LOL, I thought it was
function num1(){ function num2(){ } }
oppps
Try this
onsubmit="javascript:return (ValidateForm(this) && checkbae())"
I think that should work...
Eric
Mary Wallace
Ranch Hand
Posts: 138
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It worked.............
Million thanks!!!
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Struts Validator FrameWork = JavaScript Error
Email id validation - how this code works?
Email id validation - how this code works?
form bean and validation.
Check if an email-adress is valid with javascript
More...