| | |
javascript validation
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2006
Posts: 4
Reputation:
Solved Threads: 0
hi again! i ran into a tutorial for javascript regarding: Regxp, then i came up with this code
but it doesnt work, can somebody please guide me accordingly?
below is my current validation.js
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
} else if(name = /^ZPR\[0-9]$/) { hideAllErrors(); document.getElementById("nameError").style.display = "inline"; document.getElementById("name").select(); return false;
but it doesnt work, can somebody please guide me accordingly?
below is my current validation.js
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function checkForm() { name = document.getElementById("name").value; email = document.getElementById("email").value; if (name == "") { hideAllErrors(); document.getElementById("nameError").style.display = "inline"; document.getElementById("name").select(); return false; } else if (email == "") { hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } else if (email.indexOf("@") < 1) { // must contain @, and it must not be the first character hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } else if (email.lastIndexOf(".") <= email.indexOf("@")) { // last dot must be after the @ hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } else if (email.indexOf("@") == email.length) { // @ must not be the last character hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } else if (email.indexOf("..") >=0) { // two periods in a row is not valid hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } else if (email.indexOf(".") == email.length) { // . must not be the last character hideAllErrors(); document.getElementById("emailError").style.display = "inline"; document.getElementById("email").select(); return false; } return true; } function hideAllErrors() { document.getElementById("nameError").style.display = "none" document.getElementById("emailError").style.display = "none" }
Last edited by darylcharm; Aug 28th, 2006 at 1:04 am.
![]() |
Similar Threads
- Send a text message to your phone from your site! (ColdFusion)
- PHP: Form Validation (PHP)
- php drop down menu to search multiple sql tables (PHP)
- Simple checkbox validation question (JavaScript / DHTML / AJAX)
- best design (JSP)
- help with asp.net/JS and cookies (ASP.NET)
- Javascript, Form fields validation and submit (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Delay loading advertisements
- Next Thread: Alternating backgrounds?
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies createrange() css cursor date debugger decimal dependent design dom download dropdown element embed enter error events firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe images index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseover paypal php player position post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search security select software sql text textarea toggle unicode variables w3c webservice website window windowofwords windowsxp





