mboehler3 Posted September 2, 2011 Share Posted September 2, 2011 Hi, my form here collects the first name and last name fields, and these fields need to have the same name in order to be properly placed in our database.I have JS validation set up to make sure something is entered for email and company. But when I set something up for the name fields, the validation breaks. Here's what I have in place now: function checkrefervalues(){ message = ""; if (document.referaclient.company.value.length ==0){ message = message+"Please enter your Company Name.\n"; } if (document.referaclient.Email.value.length == 0) { message = message + "Please enter your Email Address.\n"; } else { checkemail(document.referaclient.Email.value) } if (message.length > 0){ alert(message); return false; } pageTracker._trackEvent('Accountant Forms', 'PMISubscription'); return true; } function checkemail(str){ var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ message = message + "Email address seems incorrect (check @ and .'s)\n" return false; } } function IsNumeric(sText) { var ValidChars = "0123456789"; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } var isNN = (navigator.appName.indexOf("Netscape")!=-1); function autoTab(input,len, e) { var keyCode = (isNN) ? e.which : e.keyCode; var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; if(input.value.length >= len && !containsElement(filter,keyCode)) { input.value = input.value.slice(0, len); input.form[(getIndex(input)+1) % input.form.length].focus(); } function containsElement(arr, ele) { var found = false, index = 0; while(!found && index < arr.length) if(arr[index] == ele) found = true; else index++; return found; } function getIndex(input) { var index = -1, i = 0, found = false; while (i < input.form.length && index == -1) if (input.form[i] == input)index = i; else i++; return index; } return true; } Is there any way to make sure the first and last name fields get filled out? Link to comment Share on other sites More sharing options...
jeffman Posted September 2, 2011 Share Posted September 2, 2011 Each item could have a unique id. Get your references using document.getElementById Link to comment Share on other sites More sharing options...
mboehler3 Posted September 2, 2011 Author Share Posted September 2, 2011 Each item could have a unique id. Get your references using document.getElementByIdThanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.