javascript - Verify Alphabet Textbox only -



javascript - Verify Alphabet Textbox only -

how verify text boxes? jsp page created take in information.

first name should no have numbers in there, can come in name "103249" , text box takes it. also, how prepare lastly name well?

var btn = ""; function validate(myform) { if (btn == "submit") { //validate form on 'submit' button (not 'clear' button) var num = 0; var message = ""; if(myform.firstname.value == "") { message += "- first name must completed \n"; num = 1; } if(myform.lastname.value == "") { message += "- lastly name must completed \n"; num = 1; } if(myform.dateofbirth.value == "") { message += "- date of birth must completed \n"; num = 1; } //radio button validation var g = ""; //loop thru each radio button, verify if "checked" (var i=0; i<myform.gender.length; i++) { if (myform.gender[i].checked) { //changes value of "g" if value selected g = myform.gender[i].value; } } //if no radio button selected, "g" still = "" if (g == "") { message += "- gender must completed \n"; num = 1; } if(myform.gpa.value == "") { message += "- gpa must completed \n"; num = 1; } //dropdown if(myform.education.value == "") { message += "- education must completed \n"; num = 1; } //dropdown if(myform.job.value == "") { message += "- occupation must completed \n"; num = 1; } //radio button validation var g = ""; //loop thru each radio button, verify if "checked" (var i=0; i<myform.married.length; i++) { if (myform.married[i].checked) { //changes value of "g" if value selected g = myform.married[i].value; } } //if no radio button selected, "g" still = "" if (g == "") { message += "- married must completed \n"; num = 1; } //if(myform.spouse.value == "") { //message += "- spouse must completed \n"; //num = 1; //} //radio button validation var g = ""; //loop thru each radio button, verify if "checked" (var i=0; i<myform.children.length; i++) { if (myform.children[i].checked) { //changes value of "g" if value selected g = myform.children[i].value; } } //if no radio button selected, "g" still = "" if (g == "") { message += "- children must completed \n"; num = 1; } //dropdown //only require if previous field children marked "yes" if(myform.numchild.value == "0" && g == "yes") { message += "- number of children must completed \n"; num = 1; } if(myform.childsupport.value == "") { message += "- kid back upwards must completed \n"; num = 1; } if(myform.creditscore.value == "") { message += "- credit score must completed \n"; num = 1; } if (num == 1) { alert ("please finish or right next required fields: \n\n"+message); homecoming false; } else { homecoming true; } //end if } //end if submit button if (btn == "delete") { //confirm if want delete var result = confirm("are sure want permanently delete survey?"); homecoming result; } //end if delete button } //end func //=============== disable ccards , number of children dropboxes ================== function handleselect(myradio){ if(myradio.value == "no"){ document.getelementbyid("cc_use").selectedindex = 0; //reset initial default value document.getelementbyid("cc_use").disabled = true; } else { document.getelementbyid("cc_use").disabled = false; } //end if } //end func function handleselect1(myradio1){ if(myradio1.value == "no"){ document.getelementbyid("numchild").selectedindex = 0; //reset initial default value document.getelementbyid("numchild").disabled = true; } else { document.getelementbyid("numchild").disabled = false; } //end if } //end func //=============== populate occupation dropdown based on industry dropdown selection ================== function configuredropdownlist(industry, occupation) { //params: id's of sending dropdown & dropdown alter //categories: create string value of list items in java arraylist of categories //it translates string opening , closing brackets: [], need delete brackets string var categoryliststring = "<%= lstcategories %>"; categoryliststring = categoryliststring.replace("[",""); categoryliststring = categoryliststring.replace("]",""); //split category string new javascript array of categories var categoryarray = new array(); categoryarray = categoryliststring.split(", "); //make sure it's comma + space //occupations: create string value of nested list items in java arraylist of arraylists: occup names each category //it translates string opening , closing double brackets: [[]], need delete brackets string var occupbycatsstring = "<%= loccp %>"; occupbycatsstring = occupbycatsstring.replace("[[",""); occupbycatsstring = occupbycatsstring.replace("]]",""); //split string new javascript array var occupationsarray = new array(); occupationsarray = occupbycatsstring.split("], ["); //loop thru array , break farther individual nested arrays occup names in each category (var = 0; < occupationsarray.length; i++) { occupationsarray[i] = occupationsarray[i].split(", "); //make sure it's comma + space } //alert("new occup name array index 0: "+occupationsarray[0]+", index 1: "+occupationsarray[1]); //alert("individ occup names in index 0, name 0: "+occupationsarray[0][0]+", name 1: "+occupationsarray[0][1]); //categories array (categoryarray) & nested occup names array category (occupationsarray) //are parallel arrays in order match category names appropriate grouping of occup names //loop thru list of categories find selected 1 //and create dropdown list of matching occup names category (var = 0; < categoryarray.length; i++) { if (industry.value == categoryarray[i]) { //call method create occupation dropdown list values //send array of category's list of occupation names parameter, , 'occupation' id value of select createoccupationitems(occupationsarray[i], occupation); } } //end } //end function function createoccupationitems(occuparr, occupation) { //parameters in: array of category's list of occupation names, , 'occupation' id value of select document.getelementbyid(occupation).options.length = 0; (var = 0; < occuparr.length; i++) { createoption(document.getelementbyid(occupation), occuparr[i], occuparr[i]); } } //end function function createoption(ddl, text, value) { var opt = document.createelement('option'); opt.value = value; opt.text = text; ddl.options.add(opt); } //end function </script>

here actual code validate:

<div class="sameline"> <label for="firstname">first name:</label> <input type="text" name="firstname" value="<%=surv.getfname()%>"> </div> <div class="sameline"> <label for="lastname">last name:</label> <input type="text" name="lastname" value="<%=surv.getlname()%>">

edit: here code found verify letters. not work, ignoring if anything:

if(myform.firstname.value.search(/[^a-za-z]+/) === -1) { message += "- first name must have letters \n"; num = 1; }

javascript jsp

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -