| | |
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 |
ajax ajaxcode ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft mimic object onmouseoutdivproblem onreadystatechange parent pdf php player post problem progressbar rated rating regex runtime scroll search security select session shopping size software sql star stars synchronous text textarea unicode validation w3c web website window windowofwords windowsxp wysiwyg xml \n





