小编yop*_*tes的帖子

给定出生日期时自动获得年龄

我想从出生之日起就知道一个人的年龄.我有一个HTML代码,我正在使用dob的datepicker,当我给出生日期时,它显示自动显示年龄而不提交.请帮我找到解决方案.

<html>
    <head>
        <title>
            DOB calculations
        </title>
        <link rel='stylesheet' type='text/css' href='jquery-ui.css' />
        <script type='text/javascript' src='jquery.min.js'>
        </script>
        <script type='text/javascript' src='jquery-ui.min.js'>
        </script>
        <script type='text/javascript' src='jquery.js'>
        </script>
        <script type='text/javascript' src='jquery-ui-custom.js'>
        </script>
        <script type='text/javascript' src='jquery.ui.datepicker.js'>
        </script>
        <script type="text/javascript">
            $(function() {

                $('#datepicker').datepicker({
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: 'mm/dd/yy',
                    //firstDay: 1,
                    onSelect: function(dateText, inst) {
                        dateText.split('/');
                        Bdate = new Date(dateText[2], dateText[0] - 1, dateText[1]);
                        BDateArr = ('' + Bdate).split(' ');
                        //document.getElementById('DOW').value = BDateArr[0]; 
                        Cdate = new Date;
                        CDateArr = ('' + Cdate).split(" ");
                        Age = CDateArr[3] …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery jquery-ui

7
推荐指数
1
解决办法
3万
查看次数

验证功能问题

您好我无法得到正确的验证.我认为此代码中存在一些错误,所以任何人都可以帮我解决这个问题.

 public static boolean validateFee(String value) {

        boolean isvalid = true;
        try {
            int fee = 0;
            if (value != null && !value.isEmpty()) {
                fee = Integer.parseInt(value);
            }
        } catch (NumberFormatException ne) {
            // ne.printStackTrace();
            isvalid = false;
            return isvalid;

        }
        return isvalid;
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码验证费用,其中使用正则表达式作为[0-9] +.这段代码我在一个公共函数中使用它.实际上验证调用是在servlet中完成的,如下所示:

private Boolean validateFee(HttpSession session, PropertiesHandler props, String number) {
    Boolean isvalid = true;
    HashMap hashMap = new LinkedHashMap();
    number = ApplicationConstants.FEE_PATTERN;
    if (!Validation.validateFee(number)) {
        isvalid = false;
        hashMap.put("time", props.getText("error.fee.invalid.type"));
    }
    session.setAttribute("errorMessage", hashMap);
    System.out.println("Map …
Run Code Online (Sandbox Code Playgroud)

java

2
推荐指数
1
解决办法
214
查看次数

用称呼表示全名的正则表达式

我想要一个正则表达式的全名与称呼.谁能帮帮我吗.

^[A-Za-z] ([A-Za-z] (\\s|\\.|_)?)+[a-zA-Z]*$
Run Code Online (Sandbox Code Playgroud)

这是我的正则表达式,我用它作为全名,但它并没有表示敬意.

regex string

1
推荐指数
2
解决办法
2919
查看次数

密码验证问题

我在进行密码验证方面遇到了麻烦.我从名为applicationconstants的java类中获取密码范围的最小值和最大值,并在servlet中调用它.我在另一个java类中使用验证函数并在servlet中调用它.请帮我解决这个问题.

servlet代码

int minLength = ApplicationConstants.PASSWORD_MIN_LENGTH;
int maxLength = ApplicationConstants.PASSWORD_MAX_LENGTH;

 if (user.getUserPassword().length() > 0 || user.getUserPassword() !=null) {
          if (Validation.validateStringLengthRange(user.getUserPassword(), minLength, maxLength)) {
             System.out.println("servlet");
              isvalidate = false;
              hashMap.put("password", props.getText("error.password.compare.outofrange"));
              session.setAttribute("errorMessage", hashMap);
           }
  }
Run Code Online (Sandbox Code Playgroud)

Validation.java

 public static boolean validateStringLengthRange(String name, int min, int max) {
        boolean isValid = true;
        int len = name.length();
        if (len > 0) {
            if (len < min || len > max) {
                System.out.println("validation.java");
                isValid = false;
            }
        }
        return isValid;
    }
Run Code Online (Sandbox Code Playgroud)

ApplicationConstants.java

public static final int …
Run Code Online (Sandbox Code Playgroud)

java

-1
推荐指数
1
解决办法
605
查看次数

空指针异常

我在这个函数中面临一些问题,我遇到了空值并获得了空指针异常.sqlDate并且sqlTime为空.

 private void setCalendarComboDetails(Map tenantConnInfo, HttpSession session, HttpServletRequest request) {
    logger.info("Enter setCalendarComboDetails");
    Appointment appointmentInfo = new Appointment();
    Date sqlDate;
    Time sqlTime;

    try {
        CompanyDbImpl companyImpl = new CompanyDbImpl(tenantConnInfo);
        PatientDbImpl patientImpl = new PatientDbImpl(tenantConnInfo);
        DoctorDbImpl doctorImpl = new DoctorDbImpl(tenantConnInfo);

        CalendarDbImpl calendarImpl = new CalendarDbImpl(tenantConnInfo);
        ConfigurationDbImpl configurationImpl = new ConfigurationDbImpl(tenantConnInfo);
        session.setAttribute("isvalid",true);
        session.removeAttribute("appointmentInfo");
       // session.removeAttribute("index");
        List<CompanyBranchDetails> branchDetailsList = companyImpl.getCompanyNBranchList();
        session.setAttribute("companyBranchList", branchDetailsList);

        List<PatientInfo> patientList = patientImpl.getPatientInfoList();
        session.setAttribute("patientInfoList", patientList);

        String whereClause = " dbd.branch_id=" + branchDetailsList.get(0).getBranchId();

        List<DoctorBranchDetails> doctorBranchDetailsList = doctorImpl.getDoctorBranchDetailsListByWhereClause(whereClause);
        System.out.println("doctor …
Run Code Online (Sandbox Code Playgroud)

java

-6
推荐指数
1
解决办法
535
查看次数

标签 统计

java ×3

html ×1

javascript ×1

jquery ×1

jquery-ui ×1

regex ×1

string ×1