Jump to content

form validation


manick

Recommended Posts

Hi all,Me again (js newbie), I am trying to validate info entered into a form but again am fairly clueless, can anybody tell me if I am anywhere near?regexp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/function ismail(isit){ if (regexp.test(form.billEmailAddress.value)){ return true } return false }function isname(isit){ if (isit==""||isit==null) return false }function istel(isit){ var num = "0123456789() ";for (var intLoop = 0; intLoop < form.billPhoneNumber.value.length; intLoop++) {if (-1 == num.indexOf(form.billPhoneNumber.value.charAt(intLoop))) return false} function validate() {if (isname(form.billFamilyName==false) {alert ("Please enter your surname");form.billFamilyName.focus();return false;}if ismail(form.billEmailAddress==false) {alert ("Please enter a valid Email Address");form.billEmailAddress.focus();return false;}if (istel(form.billPhoneNumber==false){alert ("please enter a valid telephone Number");form.billPhoneNumber.focus();return false;} return true;}I'm still a bit clueless about how it gets the info from the form as well If anybody has got any pointers?Many thanksNick Trenam

Link to comment
Share on other sites

I am trying to validate info entered into a form but again am fairly clueless, can anybody tell me if I am anywhere near?
The only way you will know if you are near is by testing it, try entering correct/incorrect info into your form and see what happens. Depending on the results you will know what areas need to be looked at
I'm still a bit clueless about how it gets the info from the form as well If anybody has got any pointers?
To get info from forms i tend to use:Form element: <input type="text" id="box1" />access it by: var first=document.getElementById('box1').value;check it by: if(first==null) etc etc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...