Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,424 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,356 people online right now. Registration is fast and FREE... Join Now!




How to merge 2 forms into one?

 
Reply to this topicStart new topic

How to merge 2 forms into one?

MasterRoger
15 Oct, 2008 - 05:30 AM
Post #1

New D.I.C Head
*

Joined: 16 Sep, 2008
Posts: 6

Does anyone would have an idea on how to merge these two forms into one? The first forms is checking for e-mail domain @123.com and the second forms check if field is not empty.Thanks for your help!

jscript

<script language = "Javascript">
function echeck(str) {

var at="@123.com"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("PLEASE USE @123.com")
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}

return true
}

function ValidateForm(){
var emailID=document.frmSample.txtEmail

if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (echeck(emailID.value)==false){
emailID.value=""
emailID.focus()
return false
}
return true
}


<script language = "Javascript">
function checkrequired(which) {
var pass=true;
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("The "+shortFieldName+" field is a required field.");
return false;
} else {
return true;
}
}

</script>


CODE

</head>
<body>
<div>
    <form name="frmSample" method="post" action="#" onSubmit="return ValidateForm()">
        <p><strong>Form 1</strong></p>
        <p>Enter an Email Address :<input type="text" name="txtEmail"></p>
        <p><input type="submit" name="Submit" value="Submit"></p>
    </form>
    
    
    <form action="/webservices/form" method="post" onSubmit="return checkrequired(this)">
    <input type="hidden" name="form" value="CsCommunityCommentEn" />
        
            <p><strong>Form 2</strong></p>
            <br>
            <div>First Name:</div>
            <div><input name="requiredfirst name" type="text" value=""/>*</div><br />
            <div>Last Name :</div>
            <div><input name="requiredlast name" type="text" value=""/>*</div><br />
            <div>Email Address :</div>
            <div><input name="requirede mail address" type="text" value=""/>*</div><br />
            <div>Select Option:</div>
            <SELECT NAME="requiredoption">
                <OPTION VALUE="" SELECTED>
                <OPTION VALUE="Suggestions">Suggestions
                <OPTION VALUE="Technical">Technical
            </SELECT>*
            <div>Feedback:</div>
            <div><textarea name="feedback" cols="46" rows="4"></textarea></div>
            <div><input name="submit" type="submit" value="Send" /><input type="reset" value="Reset" /></div><br />
            <div align="center"><strong>* indicates mandatory input required</strong></div>
  </form>
    
    
    </div>

</body>
</html>


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 01:24PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month